Skip to content

fix(mcp): revoking a default connection no longer fails with a 500 - #51

Merged
fylorn merged 1 commit into
devfrom
fix/mcp-revoke-default-promotion
Sep 24, 2026
Merged

fylorn merged 1 commit into
devfrom
fix/mcp-revoke-default-promotion

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

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 ran UPDATE … WHERE id = (SELECT id FROM mcp_user_credentials …), and mcp_user_credentials has no id column (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_label within the same (server, user).

Tests

revoking_the_default_account_promotes_the_newest_one in admin_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 warnings clean.

🤖 Generated with Claude Code

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]>
@fylorn
fylorn merged commit c25b44f into dev Sep 24, 2026
6 checks passed
@fylorn
fylorn deleted the fix/mcp-revoke-default-promotion branch September 24, 2026 09:36
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.

1 participant