fix(queue): log unrecognized job types in processJob instead of dropping silently (#5836) - #6014
Merged
JSONbored merged 1 commit intoJul 15, 2026
Conversation
…ing silently (JSONbored#5836) processJob's `switch (message.type)` in src/queue/job-dispatch.ts fanned out to dozens of handlers with no `default:` case. An unrecognized message.type — a stale queued message from a renamed/removed job type, a producer/consumer skew during a rolling deploy, or a corrupted payload — fell through and was acked by the caller with zero trace: no log line, no metric, no audit event. This was the only ack-and-drop path in the queue pipeline with no observability, unlike the `retired_review_job_ignored` (src/index.ts) and `dlq_message_dead_lettered` (src/queue/dlq.ts) precedents. Add a `default:` case that emits a structured `unknown_job_type_ignored` warning (level/event/jobType, mirroring those precedents' JSON shape) via console.warn, then returns normally. It never throws, so the existing ack-after-processJob flow is unaffected — this is purely an observability addition. No existing case branch is changed. The regression test imports processJob directly from ./job-dispatch (the file changed) and asserts the default branch logs the event without throwing, plus a negative case confirming a recognized type does not emit the warning.
Contributor
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6014 +/- ##
=======================================
Coverage 95.16% 95.16%
=======================================
Files 591 591
Lines 46934 46936 +2
Branches 15000 15000
=======================================
+ Hits 44664 44666 +2
Misses 1512 1512
Partials 758 758
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 LoopOver is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
JSONbored
approved these changes
Jul 15, 2026
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.
Summary
Closes #5836.
processJobinsrc/queue/job-dispatch.tsis the top-level Cloudflare Queues dispatcher — aswitch (message.type)that fans out to dozens of handlers with nodefault:case. If amessage.typedoesn't match any
case(a stale queued message from a renamed/removed job type, a producer/consumer versionskew during a rolling deploy, or a corrupted payload),
processJobreturned silently and the caller(
src/index.ts'squeue()handler) acked the message with zero observability — no log, no metric, no auditevent. This was the only ack-and-drop path in the queue pipeline with no log line, unlike the established
retired_review_job_ignored(src/index.ts) anddlq_message_dead_lettered(src/queue/dlq.ts) precedents.The fix adds a
default:case that emits a structuredunknown_job_type_ignoredwarning(
{ level: "warn", event: "unknown_job_type_ignored", jobType }, mirroring those precedents' JSON shape) viaconsole.warn, then returns normally. It never throws, so the existing ack-after-processJobflow isunaffected — this is purely an observability addition, not a change to message handling. No existing
casebranch is touched. (In the
default:armmessagenarrows tonever, so the runtime type is read through acast.)
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:cigate (exit 0) plusnpm audit --audit-level=moderate(0 vulnerabilities). The newdefault:branch is covered by a dedicated test that exercises it (verified via unshardednpm run test:coverage).Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.Notes on the Safety boxes: this is a backend-only observability addition to a queue dispatcher — no UI, API/OpenAPI, or auth/CORS/session surface. The logged event contains only the job type string (no secrets or private terms). The negative-path testing that applies here is the dispatcher's own: the added test covers both the unknown-type branch (logs + returns without throwing) and a recognized type (no spurious warning).
UI Evidence
Not applicable — backend-only change to a queue dispatcher; no visible UI, frontend, docs, or extension surface.
Notes
test/unit/job-dispatch.test.ts) importsprocessJobdirectly from../../src/queue/job-dispatch— the file this PR changes — so it genuinely exercises the newdefault:branch. It asserts the structuredunknown_job_type_ignoredlog (level/event/jobType) is emitted and thatprocessJobresolves without throwing, plus a negative case (a recognizedretry-orb-relaytype emits no unknown-type warning).