Skip to content

[Nitro CLI] Handle duplicated names#9649

Open
tobias-tengler wants to merge 1 commit intomainfrom
tte/handle-duplicated-names-in-cli
Open

[Nitro CLI] Handle duplicated names#9649
tobias-tengler wants to merge 1 commit intomainfrom
tte/handle-duplicated-names-in-cli

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 5, 2026 20:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Nitro CLI client to recognize duplicate-name creation failures for clients, OpenAPI collections, and MCP feature collections, so the CLI can return a friendlier error when the backend rejects a duplicate resource name.

Changes:

  • Added a new DuplicateNameError GraphQL fragment and included it in the three relevant create mutations.
  • Updated CLI command handlers to map duplicate-name mutation errors to a dedicated user-facing message.
  • Extended command tests to cover the new duplicate-name error path for client, OpenAPI, and MCP creation.

Reviewed changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Nitro/Common/src/ChilliCream.Nitro.Client/persisted/operations.json Regenerates persisted operation payloads/hashes to include the new duplicate-name fragment usage.
src/Nitro/Common/src/ChilliCream.Nitro.Client/OpenApi/Operations/CreateOpenApiCollectionCommand.graphql Adds DuplicateNameError to OpenAPI collection creation errors.
src/Nitro/Common/src/ChilliCream.Nitro.Client/Mcp/Operations/CreateMcpFeatureCollectionCommand.graphql Adds DuplicateNameError to MCP feature collection creation errors.
src/Nitro/Common/src/ChilliCream.Nitro.Client/fragments.graphql Defines the shared DuplicateNameError fragment.
src/Nitro/Common/src/ChilliCream.Nitro.Client/Clients/Operations/CreateClientCommand.graphql Adds DuplicateNameError to client creation errors.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/OpenApi/CreateOpenApiCollectionCommandTests.cs Adds coverage for duplicate-name handling in OpenAPI create command tests.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/Mcp/CreateMcpFeatureCollectionCommandTests.cs Adds coverage for duplicate-name handling in MCP create command tests.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/Clients/CreateClientCommandTests.cs Adds coverage for duplicate-name handling in client create command tests.
src/Nitro/CommandLine/src/CommandLine/Messages.cs Introduces a shared duplicate-name message helper.
src/Nitro/CommandLine/src/CommandLine/Commands/OpenApi/CreateOpenApiCollectionCommand.cs Maps OpenAPI duplicate-name errors to the new shared message.
src/Nitro/CommandLine/src/CommandLine/Commands/Mcp/CreateMcpFeatureCollectionCommand.cs Maps MCP duplicate-name errors to the new shared message.
src/Nitro/CommandLine/src/CommandLine/Commands/Clients/CreateClientCommand.cs Maps client duplicate-name errors to the new shared message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

=> $"Unexpected mutation error: {error.Message}";

public static string DuplicateName(string name, string entity)
=> $"The name '{name}' is already in use by another {entity}.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants