Skip to content

chore(discord): retire the dead discordController (TASK-137) - #1895

Merged
lilyshen0722 merged 1 commit into
mainfrom
kai/137-retire-dead-controller
Sep 25, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
kai/137-retire-dead-controller

Conversation

@lilyshen0722

@lilyshen0722 lilyshen0722 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Retires backend/controllers/discordController.ts — 187 lines, 7 exported handlers, zero importers at aeacfd8b.

Deadness, measured not inferred.

  • grep -rn discordController . over the whole worktree, excluding node_modules/.git and 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.json excludes tests only, and the image build compiles scripts/ and external/ as well, so an unresolved import anywhere in shipped code would fail here.
  • backend eslint . --ext .ts → 0 errors / 1210 warnings, identical to the recorded whole-repo baseline.
  • full backend jest tier → 444 suites / 4141 tests passed, 0 failures (24 tests and 6 suites skipped by their own guards, 4165 tests total, 244s) — the tier is the evidence that no test, fixture or setup file reached it.

One correction to the row's rationale, because it changes what a reviewer should check. The row calls this file "the accept-and-ignore botToken path". It was, before #1889; at aeacfd8b it no longer persists the field. createIntegration (:42) and updateIntegration (:103) accept botToken on the request type and deliberately ignore it, with a comment naming TASK-124 and the reason (a stored copy would shadow a later DISCORD_BOT_TOKEN rotation). 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 a botToken write here will find the opposite; the deletion stands on what follows instead.

What it does remove. createIntegration (:34, :41) and updateIntegration (:102) write a caller-supplied webhookUrl straight into discord_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) reads webhookUrl out of the request body, rejects only an empty string, and fetches it server-side — no allowlist, no scheme or host check — then returns response.status and response.ok to the caller, and on a thrown error the raw e.message. That is an SSRF with a response oracle, one router.use line 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: two webhookUrl writers are easier to move behind an envelope than three.

Effect on the TASK-124 surface. After this, no non-test code writes DiscordIntegration.botToken at all; the legacy field stays readable through resolveDiscordBotToken by design. webhookUrl keeps exactly two writers — routes/integrations.ts:441 and services/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"); fa636478 is 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 returns status + ok, and the error path returns the raw message.

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.
@lilyshen0722
lilyshen0722 added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit 4dbeb9a Sep 25, 2026
19 checks passed
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