fix(mcp): revoking a default connection no longer fails with a 500 - #51
Merged
Merged
Conversation
Revoking the account a user had marked default, on a server where they hold other accounts too (or none), always failed: the statement that promotes the newest remaining account selected `id` from `mcp_user_credentials`, which has no `id` column. The error rolled the delete back, so the account couldn't be revoked at all. Select by the table's key (server, user, account_label) instead. A test covers promoting the newest account and revoking down to none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while adding coverage for #50.
DELETE /api/mcp/connections/{server_id}/{account_label}on the account a user marked default always returned 500: the statement that promotes the newest remaining account ranUPDATE … WHERE id = (SELECT id FROM mcp_user_credentials …), andmcp_user_credentialshas noidcolumn (its key is(mcp_server_id, user_id, account_label)). Postgres rejects the statement even when no row would match, the transaction rolls back, and the account can't be revoked at all. Revoking a non-default account was unaffected, which is the only case the suite exercised.The promote statement now selects by
account_labelwithin the same (server, user).Tests
revoking_the_default_account_promotes_the_newest_oneinadmin_mcp_catalog.rs: three accounts, revoke the default → the newest remaining becomes default; revoke down to none. Fails with the 500 on current dev, passes with the fix. All MCP integration binaries pass locally (63/63); fmt and clippy--all-targets -D warningsclean.🤖 Generated with Claude Code