GeezerVison is showing github.com — fleet(queue): packet top-level max_attempts is never validated but overrides the validated payload value — a task can be born unclaimable (max_attempts <= 0) · Issue #6423 · developing-today/code
fleet(queue): packet top-level max_attempts is never validated but overrides the validated payload value — a task can be born unclaimable (max_attempts <= 0) #6423DescriptionProblem
A repo-task/v1 packet carries max_attempts in two places, and the queue validates the wrong one:
payload.max_attempts is schema-validated: manual_schema_errors (pkgs/fleet/crates/fleet-queue/src/validate.rs:108) requires it to be a positive integer.
- The top-level
packet.max_attempts is never read by validate_packet (validate.rs:433) at all — no type check, no range check, not even a warning (the design-default warning at validate.rs:492 also reads only the payload copy).
- But
task_from_packet (validate.rs:510-518) prefers the top-level field over the payload one:
let max_attempts = packet
.get("max_attempts")
.filter(|v| !v.is_null())
.or_else(|| payload.get("max_attempts"))
.cloned()
.unwrap_or(json!(4));
- The queue broker then forwards that value verbatim as
p_max_attempts to the enqueue RPC (pkgs/fleet/crates/fleet-queue/src/queue_broker.rs:347, :372).
So a packet whose top-level max_attempts is 0, negative, a string, or a float passes validation cleanly and overrides the valid payload value. This is not a theoretical field: the fleet's own producer packets carry top-level max_attempts (it is part of the repo-task/v1 envelope producers actually write), so the unvalidated copy is the operative one.
Contrast: the other top-level scalar, priority, IS validated at the top level (validate.rs:451-466, design-scale check). max_attempts is the odd one out.
Verified this run (laptop, origin/main a2b4345)
Probe ~/git/fleet/probe-queue-maxattempts — a crate calling the real fleet-queue crate's validate_packet + task_from_packet (extracted from origin/main, compiled and run on the laptop). A fully valid packet (payload max_attempts: 4) with variants:
| case |
validate errors |
task max_attempts |
| control, no top-level field |
[] |
4 |
payload max_attempts: 0 |
["payload.max_attempts: must be a positive integer"] |
0 (validation is what stops this one) |
top-level 0 |
[] |
0 |
top-level -3 |
[] |
-3 |
top-level "abc" |
[] |
"abc" |
top-level 2.5 |
[] |
2.5 |
top-level 1000000 |
[] |
1000000 |
Why it matters
- A task enqueued with
max_attempts <= 0 is born unclaimable: the claim predicate requires attempts < max_attempts (pm-stack/opencode-claimant/migration-0023.sql:103 and :261), which is false at attempts = 0. The task sits at status = queued forever, invisible to every claim, while health counts it as available work — the same silent-stall symptom as fleet(queue): tasks can sit at status=queued with attempts=max_attempts, permanently unclaimable — health reports them as available work #2937, except those tasks exhausted their attempts legitimately; these never had a first attempt available. (Whether the live RPC additionally guards the parameter could not be confirmed from this repo — the enqueue function body predates the migration copies kept here — so the fix should not rely on a database backstop.)
- A non-integer top-level value (
"abc", 2.5) is forwarded verbatim into the RPC parameter, so the failure surfaces as a raw database/RPC error at enqueue time instead of a validation error naming the field.
- An unbounded value (e.g.
1000000) silently defeats the attempt cap that the claim-eviction repair work relies on to keep poison tasks from being retried forever.
Acceptance criteria
-
validate_packet rejects a top-level max_attempts that is not a positive integer (0, negative, string, float), with an error naming the field — matching the payload rule at validate.rs:108.
- The value
task_from_packet forwards is the value that was validated: either the top-level field is validated and used, or the duplication is removed so a single source remains. A packet whose two copies disagree must not silently prefer the unvalidated one.
- A documented sane upper bound is enforced (or explicitly decided against in triage), so the attempt cap cannot be effectively disabled by a huge value.
- Tests pin: top-level 0 / -1 / "abc" / 2.5 rejected; top-level valid value honored; payload-only packet behaves exactly as before (default 4 when both are absent); disagreeing copies follow the decided rule.
- Existing validation behavior is unchanged for priority, dedupe keys, and the payload schema checks.
Related: #2937 (queued tasks at attempts=max_attempts reported as available work — the health-side symptom), #6419 / #6420 (sibling unvalidated numeric inputs on the same queue surface). Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/fleetpkgs/fleet multicall binary + platform crates on Nov 6, 2026developing-today commented on Nov 6, 2026 ContributorAuthor More actions 🤖 Agent note · filed
- Agent: new-issue-creator (new-issue-creator-code-a)
- Session / ID: cron job new-issue-creator-code-a, run 2026-11-06T02:35:00Z
- Found via: filed this run
- Task: Filed this issue — packet top-level max_attempts bypasses validate_packet but overrides the validated payload value in task_from_packet, so a task can be enqueued with max_attempts <= 0 and be born unclaimable. Verified against the real fleet-queue crate at origin/main a2b4345 (probe ~/git/fleet/probe-queue-maxattempts on the laptop).
- Expectation: effort s — triage decides the single-source/bounds fix; done when validate_packet rejects a non-positive-integer top-level max_attempts and tests pin the cases in the acceptance criteria.
- Links: probe ~/git/fleet/probe-queue-maxattempts (laptop); related issue fleet(queue): tasks can sit at status=queued with attempts=max_attempts, permanently unclaimable — health reports them as available work #2937, issue fleet(queue): repo-queue list --limit accepts 0, negative, and unbounded values — 0 silently reports '(no tasks)', and the broker forwards the value verbatim to PostgREST #6419, issue fleet(queue): repo-queue duration flags (--lease-seconds, --extend-seconds, --delay-seconds) accept 0, negative, and unbounded values — a 0/negative lease is born expired, a negative park delay defeats the park #6420
developing-today commented on Nov 6, 2026 ContributorAuthor More actions Picked up for triage: task 10863 (issue #6423) claimed by lane code-l, execution lane direct — this worker triages it in this shift: verify the cited validate.rs behavior against current main, decide the single-source/bounds rule, post findings, and route the fix.
developing-today commented on Nov 6, 2026 ContributorAuthor More actions Triage complete (task 10863): confirmed as filed, routed to fix task 10866.
Verified fresh this pass against current main 1dae17e4 (laptop clone ~/git/code, on main):
pkgs/fleet/crates/fleet-queue/src/validate.rs:108 — the positive-integer rule covers only payload.max_attempts (via manual_schema_errors).
validate_packet (validate.rs:433+) validates the top-level priority but never reads top-level max_attempts; the design-default warning at validate.rs:492 also reads only the payload copy.
task_from_packet (validate.rs:510-518) prefers the top-level value verbatim, exactly as quoted in the issue; queue_broker.rs:372 forwards it as p_max_attempts.
- Claim predicate
attempts < max_attempts confirmed at pm-stack/opencode-claimant/migration-0023.sql:261 — so max_attempts <= 0 is born unclaimable, as claimed. The creator's probe table (top-level 0 / -3 / "abc" / 2.5 / 1000000 all passing validation) is consistent with the code as read; no re-probe needed.
Triage decisions (the two points the acceptance criteria leave to triage):
- Single rule, both copies validated.
validate_packet validates the top-level field with the same positive-integer rule, error naming packet.max_attempts. If both copies are present, valid, and unequal, reject as inconsistent — no silent preference for either copy. One copy present → honored; neither → default 4.
- Ceiling enforced: 100, applied to both copies. Rationale: the largest cap legitimately used in the live queue is 48 (repair-raised caps); 100 gives ~2x headroom while defeating cap-defeat values like 1000000.
Routing: fix enqueued as task 10866 (small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:6423) carrying these decisions and the pinned test cases. Siblings issue #6419 and issue #6420 are separate surfaces with their own routing — not folded in. Related health-side symptom stays with issue #2937.
dezren39 commented on Nov 11, 2026
agent-note:v1 — state: parked (CI wait) — lane any-b, task 10866.
Fresh revalidation 2026-11-11: issue #6423 OPEN, no hard-stop labels; PR #8411 OPEN, no labels, no Codex findings, CI still pending on its head. Parked on CI per the resume plan: on green, merge PR #8411, verify validate.rs on main, complete task 10866 and close issue #6423. dezren39 commented on Nov 11, 2026 🤖 Agent note · picked up
- Agent: queue worker (repo-worker-code), lane code-b
- Session / ID: task 10866
- Found via: queue claim; execution-lane assignment
direct
- Task: Shepherd PR fix(queue): validate top-level max_attempts in validate_packet (#6423) #8411 (validate top-level
max_attempts in validate_packet, for issue fleet(queue): packet top-level max_attempts is never validated but overrides the validated payload value — a task can be born unclaimable (max_attempts <= 0) #6423) to merge and close out task 10866.
- Fresh revalidation (2026-11-11): issue fleet(queue): packet top-level max_attempts is never validated but overrides the validated payload value — a task can be born unclaimable (max_attempts <= 0) #6423 is OPEN, no hard-stop labels; PR fix(queue): validate top-level max_attempts in validate_packet (#6423) #8411 is OPEN at head
5de025c494 (1 file, pkgs/fleet/crates/fleet-queue/src/validate.rs, +52/−1). Diff audited against the triage decision (task 10863): top-level copy validated by the single rule (integer 1–100, error naming packet.max_attempts), payload copy under the same ceiling, valid-but-unequal copies rejected, single copy honored, neither defaults to 4. Codex review on 5de025c494 completed, no findings; no review threads. Lane code-p recorded cargo test -p fleet-queue --features queue-broker → 172 passed / 0 failed at this implementation (2026-11-11T03:15Z note on PR fix(queue): validate top-level max_attempts in validate_packet (#6423) #8411).
- Next: re-run the fleet-queue tests at head
5de025c494 in the existing worktree, then merge PR fix(queue): validate top-level max_attempts in validate_packet (#6423) #8411 under the standing merge authority, verify on main, close issue fleet(queue): packet top-level max_attempts is never validated but overrides the validated payload value — a task can be born unclaimable (max_attempts <= 0) #6423, and complete task 10866.
dezren39 commented on Nov 11, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|