Skip to content

fix(agent-service): return 409 Conflict for duplicate DID creation - #1769

Closed
Aadiii00 wants to merge 1 commit into
credebl:mainfrom
Aadiii00:fix/1227-duplicate-did-error
Closed

Aadiii00 wants to merge 1 commit into
credebl:mainfrom
Aadiii00:fix/1227-duplicate-did-error

Conversation

@Aadiii00

@Aadiii00 Aadiii00 commented Oct 1, 2026

Copy link
Copy Markdown

Closes #1227

Description

When creating a duplicate DID in an organization wallet via POST /v1/orgs/{orgId}/agents/did, the underlying agent returned CredoError: Key already exists, which fell through to a generic 500 "Something went wrong!" error instead of returning 409 Conflict with a clear message.

This PR catches duplicate key/DID errors during DID creation in AgentServiceService and throws an RpcException with status 409, message "DID already exist", and error "Conflict".

Changes

  • Updated createDid error handling in AgentServiceService to identify duplicate key/DID errors and return 409 Conflict.
  • Simplified checkDidExistence to throw ConflictException with standard conflict error structure.
  • Added unit tests in agent-service.service.spec.ts verifying both Credo duplicate key errors and database duplicate DID scenarios.

Signed-off-by: Aadiii00 <adityapammannavaryt@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8456e025-9cd1-483f-8f58-17e81cff0771

📥 Commits

Reviewing files that changed from the base of the PR and between 3046294 and 2fb2c90.

📒 Files selected for processing (2)
  • apps/agent-service/src/agent-service.service.spec.ts
  • apps/agent-service/src/agent-service.service.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Aadiii00 Aadiii00 closed this Oct 1, 2026
@Aadiii00 Aadiii00 reopened this Oct 1, 2026
@Aadiii00 Aadiii00 closed this Oct 1, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

fix:Incorrect error message displayed for duplicate DID creation in organization wallet

1 participant