Repository navigation
fix(fleet-queue): validate not_before at packet, client, and broker layers (#6426) - #8489
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 45 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ayers (#6426) Packet not_before and the park --not-before flag were never validated: garbage failed only as a downstream DB cast error, and a far-future value enqueued a task the claim predicate would not admit for years — born unclaimable while counting as queued. Per the triage decision on task 10871 (reject, do not clamp): - validate.rs: validate_packet now checks a present, non-null not_before with the new shared validate_not_before rule — must be a non-empty RFC 3339 timestamp string (day-in-month validated, the fallback.rs #6667 oracle) no more than 366 days in the future; every error names packet.not_before. Absent/null unchanged. - client.rs: park and revive --not-before go through validate_not_before_flag; invalid is a usage error naming --not-before (exit 2). Valid values are sent byte-for-byte as before. - queue_broker.rs: dispatch gates /park and /revive not_before before the RPC and before the turso backend dispatch; /enqueue is covered by validate_packet, which both /enqueue handlers already run ahead of their RPC call. Tests: cargo test -p fleet-queue --all-features — 200 lib + 2 integration passed, 0 failed, including 4 new tests (validate rule boundaries at a fixed now, packet-level wiring, client flag, broker gate). Oracle for the horizon cases: RFC 3339 + the 366-day rule. Queue: task 10873
8c29dcf to
0cf4b0c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c29dcf39a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// Oracle: RFC 3339 + the Gregorian calendar. | ||
| fn parse_rfc3339_epoch(s: &str) -> Option<i64> { | ||
| let s = s.trim(); | ||
| let (date, rest) = s.split_once('T').or_else(|| s.split_once(' '))?; |
There was a problem hiding this comment.
Accept lowercase RFC 3339 date/time markers
With the PostgreSQL backend, a valid timestamp such as 2026-11-06t00:00:00z now causes enqueue, park, and revive requests to fail validation. RFC 3339 permits lowercase t and z, and these values previously reached PostgreSQL's timestamp-with-time-zone conversion unchanged. The parser only recognizes uppercase T or a space here, so it rejects otherwise valid inputs before checking their date or horizon. Accept lowercase markers as well to preserve valid timestamp handling.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7fee3be — parse_rfc3339_epoch now accepts lowercase t and z markers as well as uppercase, and the horizon test's valid set gained a 2026-11-06t00:00:00z regression case. Full fleet-queue suite re-run on the new head: 202 lib + 2 integration passed, 0 failed. Thanks — that was a real regression against values PostgreSQL previously accepted.
… validation (#6426) Codex P2 on PR #8489: the new parser only recognized uppercase T/Z, but RFC 3339 permits lowercase t/z and PostgreSQL's timestamptz conversion accepted those values before this validation existed — enqueue/park/revive would have started rejecting previously valid timestamps. parse_rfc3339_epoch now accepts lowercase markers too, with a regression case in the horizon test's valid set. Queue: task 10873
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fee3be27c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let oh: i64 = op.next()?.parse().ok()?; | ||
| let om: i64 = op.next().and_then(|v| v.parse().ok()).unwrap_or(0); | ||
| (t, sign * (oh * 3600 + om * 60)) |
There was a problem hiding this comment.
Bound timezone offsets before performing epoch arithmetic
The offset hours and minutes accept arbitrary integers rather than valid RFC 3339 ranges. For example, 9999-01-01T00:00:00+70000000:00 is interpreted as a past instant and passes the 366-day gate. The Turso enqueue handler then stores the original string unchanged, and default_pick_predicate compares that string against the current timestamp, leaving this task queued but unclaimable despite passing validation. Larger offsets can also overflow the multiplication and panic in overflow-checked builds instead of returning a validation error. Validate the complete offset syntax and its component ranges before doing arithmetic.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed — parse_rfc3339_epoch now bounds the offset to the RFC 3339 time-numoffset ranges (hour 00-23, minute 00-59) before any epoch arithmetic, and the garbage set in the horizon test gained +24:00, +00:60, and the 9999-01-01T00:00:00+70000000:00 wrap example itself. Full fleet-queue suite re-run on the new head: 202 lib + 2 integration passed, 0 failed.
) Codex P2 on PR #8489 (second round): the offset parser accepted arbitrary integers, so 9999-01-01T00:00:00+70000000:00 computed as a past instant and passed the 366-day gate while the stored string still compared far-future in the claim predicate. RFC 3339 time-numoffset is a time-hour (00-23) and time-minute (00-59) — parse_rfc3339_epoch now rejects offsets outside those ranges, with regression cases (+24:00, +00:60, and the wrap example itself). Queue: task 10873
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17f527eb32
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !(0..24).contains(&hh) || !(0..60).contains(&mm) || !(0..61).contains(&ss) { | ||
| return None; | ||
| } | ||
| Some(days_from_civil(year, month, day) * 86_400 + hh * 3600 + mm * 60 + ss - offset_s) |
There was a problem hiding this comment.
Bound the year before performing epoch arithmetic
For an input such as 300000000000-01-01T00:00:00Z, the year parses successfully as an i64, but converting its civil date to epoch seconds overflows here. Overflow-checked builds panic instead of returning a validation error; release builds wrap to a negative epoch and incorrectly pass the 366-day horizon gate. With the Turso backend, verb_revive stores the original string unchanged, and default_pick_predicate compares it lexicographically against the current timestamp, leaving the revived task queued but unclaimable. Require the four-digit RFC 3339 year format before doing date arithmetic, and use checked arithmetic for the conversion.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed — parse_rfc3339_epoch now validates RFC 3339 field widths and digit shape (year 4DIGIT; month/day/hour/minute/second and offset components 2DIGIT) before any arithmetic, so no intermediate can overflow: with widths enforced the largest reachable epoch is bounded by year 9999 plus a <24h offset. Regression cases added for 300000000000-01-01T00:00:00Z, a 5-digit year, and a 1-digit month. Full fleet-queue suite re-run on the new head: 202 lib + 2 integration passed, 0 failed.
…ion (#6426) Codex P2 on PR #8489 (third round): a year with unbounded digits (300000000000-01-01T00:00:00Z) parsed as i64 and overflowed the civil-date arithmetic — panic in overflow-checked builds, wrapped negative epoch passing the horizon gate in release. RFC 3339 fixes the widths (date-fullyear 4DIGIT; month/day/hour/minute/second 2DIGIT), so parse_rfc3339_epoch now validates every field's width and digit shape before any arithmetic; with widths enforced every intermediate is provably inside i64 range. Regression cases added: the overflow example itself, a 5-digit year, a 1-digit month. Queue: task 10873
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 122b94c7bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let time = time.split('.').next()?; // drop fractional seconds | ||
| let mut tp = time.split(':'); | ||
| let hh: i64 = digits(tp.next()?, 2)?; | ||
| let mm: i64 = digits(tp.next()?, 2)?; | ||
| let ss: i64 = tp.next().and_then(|v| digits(v, 2)).unwrap_or(0); |
There was a problem hiding this comment.
Validate complete time components instead of defaulting to zero
For inputs such as 2026-11-06T00:00:bananaZ, the seconds parser fails but unwrap_or(0) converts that failure into a valid timestamp. Likewise, 2026-11-06T00:00:00.garbageZ passes because fractional content is discarded without validation. Consequently, the new packet, client, and broker gates accept malformed timestamps and forward them unchanged, leaving PostgreSQL requests to fail at the downstream cast instead of producing the intended field-specific validation error. Require valid seconds and complete consumption of the time component, and cover malformed-input rejection with the parser property tests required by AGENTS.md.
AGENTS.md reference: AGENTS.md:L41-L45
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed — present-but-invalid components are now errors throughout parse_rfc3339_epoch: seconds and offset minutes must parse as 2DIGIT when present (no silent zero), the fractional part must be non-empty digits when the . is present, and the time must be consumed completely (00:00:00:00 rejected). Regression cases added for 00:00:banana, 00:00:00.garbage, +05:xx, and the extra-component shape. Full fleet-queue suite re-run on the new head: 202 lib + 2 integration passed, 0 failed (one unrelated marker-search test flaked once with a subprocess spawn failure under parallel load; it passes alone and in the re-run).
…efore validation (#6426) Codex P2 on PR #8489 (fourth round): the seconds parser defaulted a failed parse to 0, so 2026-11-06T00:00:bananaZ validated, and the fractional part was discarded unvalidated, so 00:00:00.garbage validated too — malformed timestamps still reached the downstream DB cast instead of the field-specific error. Now: a present seconds, offset-minute, or fraction component must be valid (2DIGIT / digits only) and the time must be consumed completely (00:00:00:00 is rejected). Absent components keep the historical default. Regression cases added for each shape. Queue: task 10873
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e26657eac5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[test] | ||
| fn not_before_is_validated_against_rfc3339_and_the_366_day_horizon() { |
There was a problem hiding this comment.
Add property tests for the timestamp parser
The new timestamp parser and horizon validator are covered only by manually enumerated examples, despite having syntax, calendar, offset-equivalence, and horizon invariants. The root AGENTS.md explicitly requires property-based coverage for parsers and states that example tests do not replace it. Add generated coverage for these invariants using a named reference or invariant oracle; proptest is already a fleet-queue dev-dependency.
AGENTS.md reference: AGENTS.md:L41-L45
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Added — a proptest block in validate.rs (proptest is already a fleet-queue dev-dependency) with named oracles: calendar acceptance iff the day exists (days_from_civil/civil_from_days inverse pair), format/parse round trip over the RFC 3339 epoch range, offset equivalence (arithmetic identity), horizon acceptance iff delta ≤ 366 days (direct epoch comparison), and a no-panic property over arbitrary printable text — the overflow shapes from rounds 2–4 are exactly what that last one guards. Full suite on the new head: 207 lib + 2 integration passed, 0 failed.
…on (#6426) Codex P1 on PR #8489: the new RFC 3339 parser and horizon validator were covered only by enumerated examples, while the repo AGENTS.md requires property-based coverage for parsers. Adds a proptest block (proptest is already a fleet-queue dev-dependency) with named oracles: - calendar: a (year, month, day) triple is accepted iff it exists, valued by the days_from_civil/civil_from_days inverse pair; - round trip: any epoch in the RFC 3339 year range formats and parses back to itself (civil_from_days formatter as oracle); - offset equivalence: an offset form names the instant shifted by exactly the offset (arithmetic identity as oracle); - horizon: acceptance iff delta <= 366 days (direct epoch comparison as oracle); - robustness: arbitrary printable text never panics. Queue: task 10873
Fixes #6426 · Queue: task 10873
Problem
Packet
not_beforeand the park--not-beforeflag were never validated at any layer: garbage failed only as a downstream DB cast error, and a far-future timestamp enqueued a task the claim predicate would not admit for years — born unclaimable while counting as queued.Fix (triage task 10871 decision: reject, never clamp)
validate_packetnow checks a present, non-nullnot_beforevia the new sharedvalidate_not_beforerule: a non-empty RFC 3339 timestamp string (day-in-month validated, the fallback.rs fleet-queue(fallback): parse_ts accepts impossible dates — Feb 31 / non-leap Feb 29 / Apr 31 silently roll into the next month and shift marker lease math by days #6667 oracle) no more than 366 days in the future. Every error namespacket.not_before. Absent/null behaviour is unchanged, as are valid past/near-future values.parkandrevive--not-beforego throughvalidate_not_before_flag: invalid is a usage error naming--not-before(exit 2). A valid timestamp is sent byte-for-byte as before.dispatchgates/parkand/revivenot_beforebefore the RPC call and before the turso backend dispatch./enqueueis covered byvalidate_packet, which both/enqueuehandlers (RPC and turso) already run ahead of their insert.Out of scope per the packet: claim/park semantics for valid values, RPC signatures, the
list --not-beforefilter, the max_attempts gap (#6423), and duration-flag ranges (#6420).Tests
cargo test -p fleet-queue --all-featureson the laptop — 200 lib + 2 integration passed, 0 failed, including 4 new tests:validate::tests::not_before_is_validated_against_rfc3339_and_the_366_day_horizon— non-string/empty/garbage/impossible-date shapes rejected naming the field; exactly-at-horizon, near-future, past, offset, and fractional forms pass (fixed-now oracle).validate::tests::validate_packet_applies_the_not_before_rule— packet-level wiring; absent/null untouched.client::tests::not_before_flag_is_validated— flag rejects naming--not-before; valid values pass through unchanged.queue_broker::tests::park_and_revive_not_before_are_gated_before_the_rpc— broker gate for both verbs; other verbs ungated.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.