fix(server): reject duplicate resource names across all kinds#3612
Open
twishabansal wants to merge 28 commits into
Open
fix(server): reject duplicate resource names across all kinds#3612twishabansal wants to merge 28 commits into
twishabansal wants to merge 28 commits into
Conversation
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.
…ring # Conflicts: # internal/group/group.go
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.
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #3575
Previously only
kind: grouprejected duplicate names. Every other resource kind —source,authService,tool,toolset,embeddingModel, andpromptsilently 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:
UnmarshalResourceConfignow returns"<kind> %q declared more than once"for any repeated name, matching the behavior already in place for groups.Stacked on top of #3575