Skip to content

fix(queue): log unrecognized job types in processJob instead of dropping silently (#5836) - #6014

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/job-dispatch-unknown-type-log
Jul 15, 2026
Merged

fix(queue): log unrecognized job types in processJob instead of dropping silently (#5836)#6014
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/job-dispatch-unknown-type-log

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

Summary

Closes #5836.

processJob in src/queue/job-dispatch.ts is the top-level Cloudflare Queues dispatcher — a
switch (message.type) that fans out to dozens of handlers with no default: case. If a message.type
doesn't match any case (a stale queued message from a renamed/removed job type, a producer/consumer version
skew during a rolling deploy, or a corrupted payload), processJob returned silently and the caller
(src/index.ts's queue() handler) acked the message with zero observability — no log, no metric, no audit
event. 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) and dlq_message_dead_lettered (src/queue/dlq.ts) precedents.

The fix adds a default: case that emits a structured unknown_job_type_ignored warning
({ level: "warn", event: "unknown_job_type_ignored", 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, not a change to message handling. No existing case
branch is touched. (In the default: arm message narrows to never, so the runtime type is read through a
cast.)

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥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:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Ran the full npm run test:ci gate (exit 0) plus npm audit --audit-level=moderate (0 vulnerabilities). The new default: branch is covered by a dedicated test that exercises it (verified via unsharded npm run test:coverage).

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section 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.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

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

  • The regression test (test/unit/job-dispatch.test.ts) imports processJob directly from ../../src/queue/job-dispatch — the file this PR changes — so it genuinely exercises the new default: branch. It asserts the structured unknown_job_type_ignored log (level/event/jobType) is emitted and that processJob resolves without throwing, plus a negative case (a recognized retry-orb-relay type emits no unknown-type warning).

…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.
@shin-core
shin-core requested a review from JSONbored as a code owner July 15, 2026 06:49
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 15, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.16%. Comparing base (a211791) to head (42853bd).
⚠️ Report is 11 commits behind head on main.

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           
Flag Coverage Δ
shard-1 43.92% <0.00%> (-0.02%) ⬇️
shard-2 36.55% <0.00%> (+0.02%) ⬆️
shard-3 31.99% <0.00%> (-0.01%) ⬇️
shard-4 31.90% <0.00%> (-0.05%) ⬇️
shard-5 32.39% <0.00%> (-0.15%) ⬇️
shard-6 44.76% <100.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/queue/job-dispatch.ts 100.00% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 15, 2026
@loopover-orb

loopover-orb Bot commented Jul 15, 2026

Copy link
Copy Markdown
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

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@JSONbored JSONbored added contributor:verified Contributor passed trust analysis. and removed contributor:flagged Contributor flagged for review by trust analysis. labels Jul 15, 2026
@JSONbored
JSONbored merged commit 9c0697e into JSONbored:main Jul 15, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:verified Contributor passed trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(queue): processJob silently drops unrecognized job types with no default case or logging

2 participants