René's URL Explorer Experiment


Title: dbcrypt: `Decrypt`/`Rotate` miss several tables, causing FK violation on revoke · Issue #25381 · coder/coder · GitHub

Open Graph Title: dbcrypt: `Decrypt`/`Rotate` miss several tables, causing FK violation on revoke · Issue #25381 · coder/coder

X Title: dbcrypt: `Decrypt`/`Rotate` miss several tables, causing FK violation on revoke · Issue #25381 · coder/coder

Description: Disclosure: created using Claude Opus 4.7, validated by me Running coder server dbcrypt decrypt (and rotate) fails when any of the following tables hold rows referencing dbcrypt_keys.active_key_digest: crypto_keys.secret_key_id (migratio...

Open Graph Description: Disclosure: created using Claude Opus 4.7, validated by me Running coder server dbcrypt decrypt (and rotate) fails when any of the following tables hold rows referencing dbcrypt_keys.active_key_dig...

X Description: Disclosure: created using Claude Opus 4.7, validated by me Running coder server dbcrypt decrypt (and rotate) fails when any of the following tables hold rows referencing dbcrypt_keys.active_key_dig...

Opengraph URL: https://github.com/coder/coder/issues/25381

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dbcrypt: `Decrypt`/`Rotate` miss several tables, causing FK violation on revoke","articleBody":"_Disclosure: created using Claude Opus 4.7, validated by me_\n\nRunning `coder server dbcrypt decrypt` (and `rotate`) fails when any of the following tables hold rows referencing `dbcrypt_keys.active_key_digest`:\n\n- `crypto_keys.secret_key_id` (migration `000251_crypto_keys.up.sql`, Sep 2024)\n- `mcp_server_configs.api_key_value_key_id`, `custom_headers_key_id`, `oauth2_client_secret_key_id` (migration `000447_mcp_server_configs.up.sql`)\n- `mcp_server_user_tokens.access_token_key_id`, `refresh_token_key_id` (migration `000447_mcp_server_configs.up.sql`)\n\nExample failure:\n\n```\n2026-05-15 08:20:41.982 [info]  connected to postgres\n2026-05-15 08:20:41.983 [info]  decrypting user tokens  user_count=2\n2026-05-15 08:20:41.985 [info]  decrypting chat provider keys  provider_count=0\n2026-05-15 08:20:41.985 [info]  decrypting ai provider settings  provider_count=2\n2026-05-15 08:20:41.986 [info]  decrypting ai provider keys  key_count=1\nEncountered an error running \"coder server dbcrypt decrypt\", see \"coder server dbcrypt decrypt --help\" for more information\nerror: rotate ciphers: revoke key: pq: update or delete on table \"dbcrypt_keys\" violates foreign key constraint \"crypto_keys_secret_key_id_fkey\" on table \"crypto_keys\"\n```\n\n## Root cause\n\n`enterprise/dbcrypt/cliutil.go`'s `Decrypt` and `Rotate` iterate over a fixed list of tables (user_links, external_auth_links, user_chat_provider_keys, user_secrets, chat_providers, ai_providers, ai_provider_keys), clearing the `*_key_id` columns so the old dbcrypt key can be revoked. Both functions then call `RevokeDBCryptKey` for the key(s).\n\nTables added after these helpers were written are missing from the loops:\n\n- `crypto_keys` — added in #14662 (Sep 2024), `secret` is encrypted via `dbCrypt.InsertCryptoKey` (`enterprise/dbcrypt/dbcrypt.go:348`), but `cliutil.go` has no `crypto_keys` loop.\n- `mcp_server_configs` and `mcp_server_user_tokens` — added in migration `000447`, encrypted at rest but never decrypted by these commands.\n\nBecause the rows still reference `dbcrypt_keys(active_key_digest)`, Postgres rejects the revoke with the FK constraint error above. Same defect exists in `Rotate` when the old key has any rows in these tables.\n\n## Workaround\n\nManually clear the unhandled tables before re-running. For `crypto_keys` specifically:\n\n```sql\nUPDATE crypto_keys SET secret = NULL, secret_key_id = NULL;\n```\n\n(Workspace apps / OIDC convert / tailnet resume keys regenerate on demand, which is what a `decrypt` would imply anyway.)\n\nFor `mcp_server_configs` / `mcp_server_user_tokens` the equivalent clears must be done per affected column.\n\n## Fix\n\nAdd `crypto_keys`, `mcp_server_configs`, and `mcp_server_user_tokens` to both `Decrypt` and `Rotate` in `enterprise/dbcrypt/cliutil.go`. Cover each with a regression test in `enterprise/dbcrypt/cliutil_test.go` matching the existing `TestRotateAIProviders` pattern (seed a row under one cipher, rotate/decrypt, assert the FK no longer points at the revoked key).\n\nWorth auditing the `Delete` SQL (`sqlDeleteEncryptedUserTokens` in `cliutil.go`) for the same gap.","author":{"url":"https://github.com/dannykopping","@type":"Person","name":"dannykopping"},"datePublished":"2026-05-15T08:27:30Z","url":"https://github.com/coder/coder/issues/25381"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:25213a8b-5977-7287-a590-57060def28bd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB3B8:A99C2:267B662:30F2A05:6B017CDD
html-safe-nonce45fe25c65a1c1586de5adf9d3562804b2196a67c679e875548fb7285b1b9031a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0I4OkE5OUMyOjI2N0I2NjI6MzBGMkEwNTo2QjAxN0NERCIsInZpc2l0b3JfaWQiOiI5NjUxMTQyMDQ0MzQ1NjIyNjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb42c1f544b3a6ea191d41289bbf299cee1f443509ab6954a29f1e386b86101f9
hovercard-subject-tagissue:4452449622
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/25381/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8e21efb2eec56fd0f8def8c03c9eb4f84a60a5d7457b753dd7550651882a579f/coder/coder/issues/25381
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8e21efb2eec56fd0f8def8c03c9eb4f84a60a5d7457b753dd7550651882a579f/coder/coder/issues/25381
og:image:altDisclosure: created using Claude Opus 4.7, validated by me Running coder server dbcrypt decrypt (and rotate) fails when any of the following tables hold rows referencing dbcrypt_keys.active_key_dig...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedannykopping
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/coder/coder git https://github.com/coder/coder.git
octolytics-dimension-user_id95932066
octolytics-dimension-user_logincoder
octolytics-dimension-repository_id440752086
octolytics-dimension-repository_nwocoder/coder
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id440752086
octolytics-dimension-repository_network_root_nwocoder/coder
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/coder/coder/issues/25381#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fissues%2F25381
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fissues%2F25381
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=coder%2Fcoder
Reloadhttps://github.com/coder/coder/issues/25381
Reloadhttps://github.com/coder/coder/issues/25381
Reloadhttps://github.com/coder/coder/issues/25381
coderhttps://github.com/coder
coderhttps://github.com/coder/coder
Codehttps://github.com/coder/coder
Issues320 (320)https://github.com/coder/coder/issues
Pull requests470 (470)https://github.com/coder/coder/pulls
Discussionshttps://github.com/coder/coder/discussions
Actionshttps://github.com/coder/coder/actions
Projectshttps://github.com/coder/coder/projects
Security and quality49 (49)https://github.com/coder/coder/security
Insightshttps://github.com/coder/coder/insights
https://github.com/coder/coder
New issuehttps://github.com/login?return_to=https://github.com/coder/coder/issues/25381
New issuehttps://github.com/login?return_to=https://github.com/coder/coder/issues/25381
dbcrypt: Decrypt/Rotate miss several tables, causing FK violation on revokehttps://github.com/coder/coder/issues/25381#top
bughttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/dannykopping
dannykoppinghttps://github.com/dannykopping
on May 15, 2026https://github.com/coder/coder/issues/25381#issue-4452449622
feat: add schema for key rotation #14662https://github.com/coder/coder/pull/14662
https://github.com/dannykopping
dannykoppinghttps://github.com/dannykopping
on May 15, 2026https://github.com/coder/coder/issues/25381#issuecomment-4458235210
dannykoppinghttps://github.com/dannykopping
bughttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22bug%22
on May 15, 2026https://github.com/coder/coder/issues/25381#event-25566550113
BobbyHohttps://github.com/BobbyHo
on Jul 7, 2026https://github.com/coder/coder/issues/25381#event-27669615148
test(enterprise/dbcrypt): add Rotate/Decrypt/Delete regression tests (#…https://github.com/coder/coder/commit/90861ffa75ddb6036476af3f084ecc270a22801d
#…https://github.com/coder/coder/pull/26979
90861ffhttps://github.com/coder/coder/commit/90861ffa75ddb6036476af3f084ecc270a22801d
BetterAndBetterIIhttps://github.com/BetterAndBetterII
on Aug 21, 2026https://github.com/coder/coder/issues/25381#event-29789050203
fix(enterprise/dbcrypt): clear leftover FKs before key revokehttps://github.com/BetterAndBetterII/coder/commit/f6f870fdc40815cfe6e719d70d7c79036d1ccb93
https://docs.github.com/articles/closing-issues-via-commit-messages
f6f870fhttps://github.com/BetterAndBetterII/coder/commit/f6f870fdc40815cfe6e719d70d7c79036d1ccb93
ethanndicksonhttps://github.com/ethanndickson
on Sep 25, 2026https://github.com/coder/coder/issues/25381#event-31822795053
feat: rotate, decrypt, and delete encrypted chat_mcp_servers headers (#…https://github.com/coder/coder/commit/1c974608b1fb30b892efaea773a544a10f211e56
#…https://github.com/coder/coder/pull/29520
1c97460https://github.com/coder/coder/commit/1c974608b1fb30b892efaea773a544a10f211e56
Sign up for freehttps://github.com/signup?return_to=https://github.com/coder/coder/issues/25381
Sign in to commenthttps://github.com/login?return_to=https://github.com/coder/coder/issues/25381
bughttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.