Repository navigation
chore(discord): retire the dead discordController (TASK-137) - #1895
Merged
Merged
Conversation
backend/controllers/discordController.ts is 187 lines and 7 exported handlers with zero importers at aeacfd8: a repo-wide search for the module name outside the file itself returns nothing, tests included, and the build compiles without it (tsc -p tsconfig.build.json --noEmit exits 0). No test file references it either, so nothing is deleted beside it. The rationale on the row needs one correction. The file no longer persists a client-supplied `botToken` — it accepts the field and ignores it, with a comment naming TASK-124 and the reason (a stored copy would shadow a later DISCORD_BOT_TOKEN rotation). That write-site claim was true before #1889 and is stale now. What remains is worse in a different place: `createIntegration` and `updateIntegration` write a caller-supplied `webhookUrl` straight into the row, the one field in this collection that is a secret in its own right, while the live connect path derives that value from the Discord API instead of the request body; and `testWebhook` POSTs to any URL the caller names. Unmounted code that would do that is one router line away from doing it. After this, no non-test code writes DiscordIntegration.botToken at all. webhookUrl keeps two writers — routes/integrations.ts:441 and services/discordService.ts:322 — which is the surface TASK-124 part 2 has to encrypt. No schema, no migration, no runtime path: the file is not mounted.
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.
Retires
backend/controllers/discordController.ts— 187 lines, 7 exported handlers, zero importers ataeacfd8b.Deadness, measured not inferred.
grep -rn discordController .over the whole worktree, excludingnode_modules/.gitand the file itself: 0 hits, in any file type, tests included. An import of this module has to name it, so a name-shaped search is sufficient here, and the file's own 187 lines are the positive control that the same grep would have found.tsc -p tsconfig.build.json --noEmit→ exit 0 with the file gone.tsconfig.build.jsonexcludes tests only, and the image build compilesscripts/andexternal/as well, so an unresolved import anywhere in shipped code would fail here.eslint . --ext .ts→ 0 errors / 1210 warnings, identical to the recorded whole-repo baseline.One correction to the row's rationale, because it changes what a reviewer should check. The row calls this file "the accept-and-ignore
botTokenpath". It was, before #1889; ataeacfd8bit no longer persists the field.createIntegration(:42) andupdateIntegration(:103) acceptbotTokenon the request type and deliberately ignore it, with a comment naming TASK-124 and the reason (a stored copy would shadow a laterDISCORD_BOT_TOKENrotation). So this deletion does not remove a stored-copy path — that path is already closed, and the guard that closes it is visible in the file being deleted. Reviewers checking for abotTokenwrite here will find the opposite; the deletion stands on what follows instead.What it does remove.
createIntegration(:34,:41) andupdateIntegration(:102) write a caller-suppliedwebhookUrlstraight intodiscord_integrations— the one field in that collection that is a secret in its own right, since the URL authenticates by itself — whereas the live connect path derives that value from the Discord API (routes/integrations.ts:441).testWebhook(:154-163) readswebhookUrlout of the request body, rejects only an empty string, andfetches it server-side — no allowlist, no scheme or host check — then returnsresponse.statusandresponse.okto the caller, and on a thrown error the rawe.message. That is an SSRF with a response oracle, onerouter.useline from reachable, and the second channel is not incidental: a resolved-but-closed port and a name that will not resolve do not look alike in an error string. This deletion removes a primitive, not housekeeping. Removing it is also what makes TASK-124 part 2 tractable: twowebhookUrlwriters are easier to move behind an envelope than three.Effect on the TASK-124 surface. After this, no non-test code writes
DiscordIntegration.botTokenat all; the legacy field stays readable throughresolveDiscordBotTokenby design.webhookUrlkeeps exactly two writers —routes/integrations.ts:441andservices/discordService.ts:322(lazy backfill) — which is the surface part 2 has to encrypt.Risk. None in the running system: not mounted, not imported, no schema change, no data touched, nothing to migrate.
Gate: @vera — the deletion and the deadness argument. The corrected paragraph above is the part I would most want checked against the row, since the ask's stated reason is stale and I have not moved the row's text.
Body edited after the gate cleared, head unmoved. vera's framing above replaced a weaker sentence ("harmless while unmounted");
fa636478is byte-identical to the head she cleared, so the clearance stands on the code she read. The refinement in it is measured, not asserted: the oracle returnsstatus+ok, and the error path returns the raw message.