Skip to content

fix(configstore): improve error message when API key name conflicts across providers - #3574

Merged
akshaydeo merged 1 commit into
devfrom
05-18-fix_configstore_improve_error_message_when_api_key_name_conflicts_across_providers
May 18, 2026
Merged

fix(configstore): improve error message when API key name conflicts across providers#3574
akshaydeo merged 1 commit into
devfrom
05-18-fix_configstore_improve_error_message_when_api_key_name_conflicts_across_providers

Conversation

@SahilChoudhary22

@SahilChoudhary22 SahilChoudhary22 commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Improves the error message returned when an API key name conflicts across providers. Instead of the generic "a record with this name already exists", users now see a clear message telling them to rename the key.

Changes

  • rdb.go: Added a specific error message in parseGormError for `config_keys.name) unique constraint violations

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Try adding or updating a provider with an API key name that already exists under another provider. The error should now show the improved message.

cd framework/configstore && go test ./...

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Security considerations

None — error message change only.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c152bf02-42f4-4a66-89f5-7222fa00c8ac

📥 Commits

Reviewing files that changed from the base of the PR and between bcfb95a and caf6cd9.

📒 Files selected for processing (1)
  • framework/configstore/rdb.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • framework/configstore/rdb.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messaging for API key name conflicts: when a duplicate API key name is detected, users now receive a clear, specific message explaining the conflict and instructions to rename the key in the UI or in config.json.

Walkthrough

parseGormError now recognizes unique-constraint errors for the API key name (config_keys.name or idx_key_name) and returns a dedicated "must be unique across providers" message directing users to rename the key; other unique violations remain unchanged.

Changes

API key name uniqueness error messaging

Layer / File(s) Summary
API key name duplicate error message
framework/configstore/rdb.go
parseGormError detects unique-constraint violations on the name column (including idx_key_name) and returns a specialized API-key-name message instructing users to rename the key in the UI or config.json.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through logs and found a name clash bright,
A gentle nudge now guides by UI light.
"Rename your key" the message sings, concise and clear,
No more guessing—just a friendly steer.
Hooray, small fixes make the path more right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: improving an error message for API key name conflicts across providers, which aligns with the implementation in rdb.go.
Description check ✅ Passed The description follows the template structure with all major sections completed: Summary, Changes, Type of change, Affected areas, How to test, Breaking changes, and Checklist. All required information is present and well-documented.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-18-fix_configstore_improve_error_message_when_api_key_name_conflicts_across_providers

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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 and usage tips.

@CLAassistant

CLAassistant commented May 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@SahilChoudhary22
SahilChoudhary22 force-pushed the 05-18-fix_configstore_improve_error_message_when_api_key_name_conflicts_across_providers branch 3 times, most recently from 1d2e351 to 3e9dcfa Compare May 18, 2026 13:19
@SahilChoudhary22
SahilChoudhary22 marked this pull request as ready for review May 18, 2026 13:21
@greptile-apps

greptile-apps Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is limited to improving a single error message string, correctly preserves the ErrAlreadyExists sentinel for upstream errors.Is checks, and tightly scopes the new branch to the config_keys table.

The change adds seven lines that improve a user-facing error message. The constraint identifiers used (config_keys.name for SQLite, idx_key_name for PostgreSQL) match the GORM tag on TableKey.Name exactly. ErrAlreadyExists is wrapped with %w so all existing errors.Is callsites in the HTTP transport continue to produce HTTP 409 responses. No logic affecting data reads, writes, or migrations is touched.

No files require special attention beyond the missing test for the new parseGormError branch in rdb.go.

Important Files Changed

Filename Overview
framework/configstore/rdb.go Adds a scoped error message for config_keys.name uniqueness violations, correctly wrapping ErrAlreadyExists with %w and matching both SQLite (config_keys.name) and PostgreSQL (idx_key_name) constraint identifiers; no test for the new branch.

Reviews (3): Last reviewed commit: "fix(configstore): improve error message ..." | Re-trigger Greptile

Comment thread framework/configstore/rdb.go Outdated
Comment thread framework/configstore/rdb.go Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@framework/configstore/rdb.go`:
- Around line 393-395: The special-case branch for columnName == "name" must
preserve wrapping with ErrAlreadyExists so callers can detect it via errors.Is;
change the return to use fmt.Errorf with the %w verb (e.g. return
fmt.Errorf("API key names must be unique across providers. Rename it in the UI
or config.json: %w", ErrAlreadyExists)) inside the same conditional (the branch
that checks columnName == "name") so it mirrors how other unique-constraint
paths wrap ErrAlreadyExists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9224000c-1123-49e2-9dc3-ff9b64e653ad

📥 Commits

Reviewing files that changed from the base of the PR and between 89a99f0 and 3e9dcfa.

📒 Files selected for processing (1)
  • framework/configstore/rdb.go

Comment thread framework/configstore/rdb.go Outdated
@SahilChoudhary22
SahilChoudhary22 force-pushed the 05-18-fix_configstore_improve_error_message_when_api_key_name_conflicts_across_providers branch from 3e9dcfa to bcfb95a Compare May 18, 2026 13:27
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 18, 2026
Comment thread framework/configstore/rdb.go
@SahilChoudhary22
SahilChoudhary22 force-pushed the 05-18-fix_configstore_improve_error_message_when_api_key_name_conflicts_across_providers branch from bcfb95a to caf6cd9 Compare May 18, 2026 13:34
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.

3 participants