Skip to content

fix(server): reject duplicate resource names across all kinds#3612

Open
twishabansal wants to merge 28 commits into
feat/groupsfrom
feat/groups-pr1c1-dedup-primitives
Open

fix(server): reject duplicate resource names across all kinds#3612
twishabansal wants to merge 28 commits into
feat/groupsfrom
feat/groups-pr1c1-dedup-primitives

Conversation

@twishabansal

@twishabansal twishabansal commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #3575

Previously only kind: group rejected duplicate names. Every other resource kind — source, authService, tool, toolset, embeddingModel, and prompt silently kept the last declaration when a name was reused within a config, so a duplicated resource would be dropped with no error.

This makes duplicate detection uniform: UnmarshalResourceConfig now returns "<kind> %q declared more than once" for any repeated name, matching the behavior already in place for groups.

Stacked on top of #3575

twishabansal and others added 28 commits June 22, 2026 15:47
Introduce internal/group as the source of truth for a named collection of
tools and prompts. Group.Initialize reuses the toolset/promptset Initialize
logic; ToToolset/ToPromptset project the legacy views keyed by the group name.
No existing behavior changes yet.
Embed the initialized Toolset and Promptset in Group instead of
flattening their fields, so ToToolset/ToPromptset return the views
with their lookup sets intact rather than rebuilding them per call.
Replace the toolset/promptset maps with an authoritative groups map and
derive the toolset/promptset views from it via ToToolset/ToPromptset.
Legacy kind: toolsets configs convert to tools-only groups at init, and
the default nameless group holds all tools and prompts. No YAML surface
change; kind: groups parsing is deferred to a follow-up.
Add parsing for `kind: group` documents (flat and nested `groups:`
blocks) in UnmarshalResourceConfig, returning parsed GroupConfigs.
Validate duplicate default/named groups and reject a default group
that declares tools or prompts. Wire GroupConfigs through config
merge, reload, and initializeGroups so kind: group definitions
override same-named toolsets.
Decouple Group from the legacy tools.Toolset/prompts.Promptset types per
review feedback. Group now keeps its own O(1) tool/prompt membership sets and
exposes ContainsTool/ContainsPrompt directly, instead of deriving and storing
full toolset/promptset views. Per-tool and per-prompt manifests are generated
on demand by callers from the resolved tools/prompts maps, so the group no
longer needs serverVersion at Initialize.
Convert toolset configs to group.GroupConfig at the unmarshal boundary
and drop ToolsetConfigs. UnmarshalResourceConfig now returns 7 values;
initializeGroups and the cmd --toolset filter read only GroupConfigs.
Decode the resource map directly instead of stripping the name key first;
GroupConfig carries a yaml:"name" tag, so the strict decoder handles it and
the name is seeded up front. Merge the two group-parsing tests into one
table-driven test that asserts the full returned GroupConfig, and cover the
kind:toolset fold path.
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
UnmarshalYAMLGroupConfig returns group.GroupConfig by value, so nil does
not compile; restore group.GroupConfig{} on the decode error path.
Treat the default (nameless) group like any other group when reporting
merge conflicts, rather than special-casing its message.
Treat any kind: group as targeting the default nameless group when name
is absent, and use a single uniform "declared more than once" error for
duplicate groups regardless of name.
Previously only kind: group rejected duplicate names; source,
authService, tool, toolset, embeddingModel, and prompt silently kept the
last declaration when a name was reused within a config. Return an error
for duplicates uniformly across every resource kind.
@twishabansal twishabansal requested a review from a team as a code owner July 13, 2026 15:51
@twishabansal twishabansal added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 13, 2026
@twishabansal twishabansal changed the title feat(server): reject duplicate resource names across all kinds fix(server): reject duplicate resource names across all kinds Jul 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds validation to prevent duplicate resource configurations (sources, auth services, tools, toolsets, embedding models, and prompts) from being declared more than once in UnmarshalResourceConfig. It also introduces a comprehensive unit test suite TestDuplicateResourceConfig to verify this behavior. No review comments were provided, and the implementation is clean and well-tested.

Base automatically changed from feat/groups-pr1c-parsing to feat/groups-pr1b-wiring July 13, 2026 15:53
Base automatically changed from feat/groups-pr1b-wiring to feat/groups July 14, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants