Repository navigation
chore(discord): clear the stored bot-token copies once the env resolver is live (TASK-124) - #1891
Merged
Merged
Conversation
…er is live (TASK-124) The data half of TASK-124, deliberately separate from #1889 (`cce68b58`), which stopped reading and writing the copy. This removes it: three live rows carry a 72-char token Discord revoked (401 against GET /users/@me, measured read-only from inside the backend pod). Ordering is the reason it is separate: the pre-#1889 build still read the stored copy on two paths with no env fallback, so clearing it before that image was replaced would have broken those paths. Merge -> deploy -> acceptance read -> this script. Dry run by default; `--apply` writes. Idempotent. Scope is one collection: `discord_integrations.botToken`. `Integration.config.botToken` is a different store, never written, and still the resolver's fallback read, so it is reported and never touched.
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.
What this is
The data half of TASK-124, cut from
main(cce68b58) and deliberately separate from #1889, which stopped the read and the write. This removes the stored copies.Three live
discord_integrationsrows carry a 72-charbotTokenthat Discord has already revoked — 401 againstGET /users/@me, measured read-only from inside the backend pod. #1889 routed every read throughresolveDiscordBotToken()(env first, the stored copy only as a fallback) and stopped writing it, so the copies are unreachable. This deletes them rather than leaving a revoked credential at rest for a future code path to find.Why it is a separate step, and why it runs last
The pre-#1889 build still read the stored copy on two paths with no env fallback (
discordService.tsfetchMessagesandgetChannels). Clearing before that image was replaced would have broken those paths on the old build. Order: merge → deploy → acceptance read → this script. The script's header states the order so a future operator cannot run it early by accident.Scope: one collection
discord_integrations.botTokenonly, and only where it holds a non-empty string. Absent,nulland''are not copies of a credential, and''is exactly what the deaddiscordControllerpath used to write.$unset, not$set: ''— leaving the field behind is the failure this field already demonstrated once.Integration.config.botTokenis a different store in a different collection, never written by any writer (measured live: absent on all three rows), and still the resolver's fallback read. It is counted and logged, never touched. A non-zero count is worth seeing: it would mean some row's authority is a config field rather than the env.--applywrites. Idempotent: a second run finds nothing.sha256[:12] (n chars)— enough to tell the copies apart in a log or a ticket, never the token.Witnesses (6)
null/''/ absent are out of scope--apply$existson the rows that had a copy — a$set: ''update passes every "no copy left" query while leaving a field behind--applyreports 0 candidates / 0 clearedIntegration.config.botTokensurvives the clearMutation ledger — 5 arms, all red, each naming its own witness
--apply$unset→$set: { botToken: '' }{ $exists: true }Integration.configcount forced to 0Base and restored: 6 passed / 6. No survivors to disclose.
Full tier
jest __tests__/unit/scripts/— 20 suites / 165 tests / 0 failures.eslinton both touched files under the gated.tsoverride — 0 problems.require.main === moduleguard, sounguardedScriptImportersstays green.Not in this PR
No change to
resolveDiscordBotToken, no change to any read path, nowebhookUrlencryption (a later piece), and no change toIntegration.config.