fix(configstore): improve error message when API key name conflicts across providers - #3574
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughparseGormError 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. ChangesAPI key name uniqueness error messaging
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
1d2e351 to
3e9dcfa
Compare
Confidence Score: 5/5Safe 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
Reviews (3): Last reviewed commit: "fix(configstore): improve error message ..." | Re-trigger Greptile |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
framework/configstore/rdb.go
3e9dcfa to
bcfb95a
Compare
bcfb95a to
caf6cd9
Compare

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
parseGormErrorfor `config_keys.name) unique constraint violationsType of change
Affected areas
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.
Screenshots/Recordings
N/A
Breaking changes
Security considerations
None — error message change only.
Checklist