Skip to content

Fixes duplicate connection names#7093

Merged
MartinM85 merged 1 commit intopnp:mainfrom
milanholemans:fix-connectionName
Jan 8, 2026
Merged

Fixes duplicate connection names#7093
MartinM85 merged 1 commit intopnp:mainfrom
milanholemans:fix-connectionName

Conversation

@milanholemans
Copy link
Copy Markdown
Contributor

Closes #6174

Copilot AI review requested due to automatic review settings January 5, 2026 21:46
Copy link
Copy Markdown

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 fixes issue #6174 by adding validation to prevent duplicate connection names when creating or renaming connections. The implementation migrates from the old validation pattern to Zod schema validation with async refine callbacks that check for duplicate names by querying all existing connections.

Key changes:

  • Adds Zod schema validation with async duplicate name checking for the connection set and login commands
  • Updates CLI core to use safeParseAsync instead of safeParse to support async validation
  • Updates tests to reflect the new validation approach and adds coverage for duplicate name validation

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/m365/connection/commands/connection-set.ts Migrates from old validation methods to Zod schema with async duplicate name checking for the newName option
src/m365/connection/commands/connection-set.spec.ts Updates tests to use schema-based validation and adds test coverage for duplicate name validation
src/m365/commands/login.ts Adds async duplicate name validation for the connectionName option using Zod refine
src/m365/commands/login.spec.ts Adds test coverage to verify validation fails when connection name is already in use
src/cli/cli.ts Changes from safeParse to safeParseAsync to support async validation in Zod schemas

Comment thread src/m365/connection/commands/connection-set.ts
Comment thread src/m365/connection/commands/connection-set.spec.ts Outdated
@MartinM85 MartinM85 self-assigned this Jan 8, 2026
Copy link
Copy Markdown
Contributor

@MartinM85 MartinM85 left a comment

Choose a reason for hiding this comment

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

Looks great. Just a few minor suggestions from my side.

Comment thread src/m365/connection/commands/connection-set.ts Outdated
Comment thread src/m365/commands/login.spec.ts Outdated
@MartinM85 MartinM85 marked this pull request as draft January 8, 2026 14:21
@milanholemans milanholemans marked this pull request as ready for review January 8, 2026 15:02
Copy link
Copy Markdown
Contributor

@MartinM85 MartinM85 left a comment

Choose a reason for hiding this comment

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

Approved.

@MartinM85 MartinM85 merged commit f2b45bc into pnp:main Jan 8, 2026
10 checks passed
@milanholemans milanholemans deleted the fix-connectionName branch January 8, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection name is not unique

3 participants