Skip to content

fix(schedules): legacy IANA timezone aliases resolve end-to-end — images, validator, and scheduler classification (#1823) - #2071

Merged
vybe merged 11 commits into
devfrom
vybe/issue-1823
Aug 9, 2026
Merged

vybe merged 11 commits into
devfrom
vybe/issue-1823

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

Fixes #1823

A schedule created with a legacy IANA timezone alias (Europe/Kiev) returned a raw 500. Reproducing it turned up five defects, not the three the issue describes — and the fifth is the one that made the symptom permanent.

The five defects

# Layer Defect
1 Image packaging docker/{backend,scheduler}/Dockerfile are FROM python:3.13-slim with no codename pin, so both images silently migrated bookworm→trixie. Debian 13 split the IANA backward-compatibility links out of tzdata into a separate tzdata-legacy package, so /usr/share/zoneinfo/Europe/Kiev simply stopped existing — without anyone changing a line.
2 Validator robustness zoneinfo.ZoneInfoNotFoundError is a KeyError subclass, so it escaped validate_cron_expression's except (ValueError, TypeError) and surfaced as an unhandled 500. The validator also probed pytz only — but pytz bundles its own complete database and accepts every alias everywhere, while APScheduler's astimezone() re-resolves through zoneinfo. #1472 mirrored the scheduler's visible first step and missed the re-resolution behind it.
3 Env-dependent test tests/unit/test_1472_schedule_validation.py carried Europe/Kiev as a valid fixture and passed on CI — because tests/requirements-test.txt declares tzdata (#1771) — while the same test failed inside the shipped image.
4 Update path (from @webmixgamer's comment) The PUT route calls validate_timezone only, and that function was pytz-only — so an unresolvable alias was silently persisted with 200 OK instead of 500ing. Same contract, opposite failure mode: create was loud and wrong, update was quiet and wrong.
5 Found by reproduction — NOT in the issue src/scheduler/service.py::_add_job classified ZoneInfoNotFoundError as transient. Because it is a KeyError subclass it is not a ValueError, so it fell through the permanent arm into the broad except Exception. The row was never snapshotted into _permanent_add_failures, so #1472's bounded-retry machinery was defeated: it retried every 60 s forever, logged an ERROR on every sync tick, and froze next_run_at into exactly the "Next: Nd ago" symptom #1472 existed to eliminate — which canary E-06 fires on every cycle.

Defects 2 and 4 are two halves of one split-brain: the create route calls only validate_cron_expression, the update route only validate_timezone, so two probes meant two contracts. The fix delegates — validate_cron_expression now calls validate_timezone — leaving exactly one place where the timezone contract is defined.

Why it hid for months

CI was more capable than production. #1771 added tzdata to tests/requirements-test.txt, so the alias resolved on every CI runner. The images then quietly lost the same capability via the floating base tag. The test environment being strictly more capable than the runtime is the inversion that keeps a packaging defect green — and no unit test can detect it by construction.

Proof, in the shipped images

Everything below is from the WAVE-4 /verify-local --skip-agent run (project trinity-verify-424a80d3) — the only place AC 1 and AC 4 are provable, since every unit assertion here is static or fault-injected.

tzdata-legacy resolves on trixie, in BOTH images (this was the single unverifiable claim in the plan, and it gated both builds):

backend   layer #7:  Get:225 http://deb.debian.org/debian trixie/main arm64 tzdata-legacy all 2026b-0+deb13u1 [183 kB]
                     Setting up tzdata-legacy (2026b-0+deb13u1) ...
scheduler layer #33: #33 7.237 Get:23 ... tzdata-legacy all 2026b-0+deb13u1 [183 kB]
                     #33 8.083 Unpacking tzdata-legacy (2026b-0+deb13u1)

No Unable to locate package, no E: — the recorded apt-fails fallback was not needed and not applied.

  • zoneinfo.ZoneInfo('Europe/Kiev') → Europe/Kiev, exit 0, in backend and scheduler
  • backed by the real on-disk symlink /usr/share/zoneinfo/Europe/Kiev -> Kyiv
  • dpkg -l tzdata-legacy → ii … 2026b-0+deb13u1 in both
  • pip show tzdata → 2026.3 (matches the exact pin)
  • in-image pytest, test_1472_schedule_validation.py + test_1823_tz_capability_parity.py run inside the backend image — the exact run that originally surfaced the bug — 55 passed; the named detector test_runtime_resolves_legacy_tz_aliases passed
  • scheduler container boots healthy and registers 3 jobs under APScheduler==3.11.0: state=running health=healthy restarts=0, GET /health 200; driving the real _add_job chain (pytz → CronTrigger → astimezone() → zoneinfo) in-image gives Europe/Kiev → next_run=2026-08-10 09:00:00+03:00, Europe/Kyiv identical, UTC → +00:00
  • negative: Not/AZone → ScheduleValidationError: Unknown timezone, which the router maps to 400, not 500; a fault-injected empty TZPATH + hidden wheel yields the distinct named error rather than a raw KeyError

Two deliberate changes, each independently droppable

Both were flagged at implement time as scope questions and both were ruled KEEP on technical merit at review — recorded here so a reviewer can disagree cheaply.

ac2a7e8c — a cron-only PUT returns 400 instead of 200. The route validated the new cron against a hardcoded "UTC", so a row already storing an unresolvable zone was mutated and re-blessed with 200 OK while the scheduler still could not register it. It now validates against the row's effective zone. This is the PR's one behaviour regression, and it is bounded by "the row is already non-firing" — a bound that now holds cleanly only because 783c3120 closed the "" hole below. Cron verdicts are unchanged (field parsing is timezone-independent, pinned by the branch's own bad-cron and healthy-row tests). Post-packaging-fix the branch is unreachable: 0 of 596 pytz zones are unresolvable, measured.

ac644486 — APScheduler>=3.10.0,<4.0.0 → ==3.11.0 in docker/scheduler/requirements.txt. The implement stage stated plainly that this is not required for the fix to work, and the orchestrator leaned DROP. That lean was wrong: the divergence is current state, not hypothetical — the floor resolves to 3.11.3 on PyPI today while the backend pins 3.11.0, so building both images right now yields a validator and an executor running different copies of the parser that #1472's contract is stated against. astimezone() is the exact function that caused this bug. Now guarded by a parity test rather than left to a comment — closing a gap the commit's own comment declared ("Nothing ties these two declarations together yet").

The falsy-evaluation fix (783c3120)

An independent Gemini review claimed the effective-timezone expression updates.timezone or schedule.timezone or "UTC" was wrong for an explicit empty string. It was reachable, and proven so by driving the real handler rather than by reading it: ScheduleUpdateRequest.timezone is a bare Optional[str] with no validator, "" clears Pydantic, validate_timezone("") early-returns by design, model_dump(exclude_unset) carries timezone: "", and db/schedules/crud.py::update_schedule writes it verbatim with no falsy guard. Measured: a PUT {"cron_expression": …, "timezone": ""} handed the validator Europe/Kiev while persisting "".

The harm inverts ac2a7e8c's own justification: on a tz-incomplete runtime the new 400 rejected the one request that repairs the row — clearing a stale alias back to the scheduler default. Fixed with presence-not-truthiness (updates.timezone if updates.timezone is not None else schedule.timezone, then or "UTC"), with 2 regression tests verified RED against the pre-fix expression. The create path's or "UTC" is deliberately untouched — it has no middle fallback term, so "" or "UTC" already equals the effective value.

Coverage — stated honestly

The integration stage did not run. verify-local's own result.json records status="fail". The integration stage aborted at collection after 0.45 s (Interrupted: 5 errors during collection), so the suite never executed and this branch has zero integration-level evidence beyond boot+health. This is an absence of coverage, not a green.

The cause is pre-existing #2037, proven branch-independent rather than assumed: tests/utils is a tracked symlink → testing_utils (mode 120000, blob 4e7b2eaf) present at origin/dev, which shadows src/backend/utils, and testing_utils has no safe_yaml.py. All 5 failing files have 0 diff lines versus base, and the 10 backend modules importing utils.safe_yaml are disjoint from the 10 files this branch touches.

No agent-side verification was performed (--skip-agent). That is acceptable only because docker/base-image/** is untouched — verified, git diff --name-only ef3b0ebf..HEAD -- docker/base-image/ returns 0 files — and the agent container performs no schedule validation and registers no CronTrigger. It is still a stated gap.

Stage results: preflight pass · unit pass, 8466 passed / 18 skipped / 0 failed (478 s) · build+import-smoke pass (84 s) ← the gating stage · agent-build skipped · boot+health pass · agent-exercise skipped · integration fail (collection abort, above).

Tests

Run Result
Full unit suite, in the verify venv (WAVE 4) 8466 passed, 18 skipped, 0 failed (478 s)
Full unit suite, post-review (WAVE 3) 8344 passed, 22 skipped, 0 failed (480 s)
In-image, backend image: test_1472 + test_1823_tz_capability_parity 55 passed
test_1472_schedule_validation.py + test_1823_*.py (ship re-confirm) 72 passed
Schedule neighbourhood -k "schedule or template_schedules or compatibility" 565 passed, 9 skipped

Every new test was proven non-vacuous by reverting its fix and observing the red: packaging guard without tzdata-legacy/tzdata → 2 failed; update-route test against the pre-fix validator → 1 failed; scheduler classification against the unfixed service → 2 failed; cron-only PUT against the unmodified router → 3 failed; the falsy-eval pair → red against the pre-fix expression.

The fault-injected tests carry an explicit docstring disclaiming environmental proof — with the packaging fix in place there is no natural input that reaches the ZoneInfoNotFoundError backstop (0/596 zones unresolvable), so those tests prove our exception-type mapping, not that any environment is broken. The environmental claims are carried by the in-image checks above and by test_1823_tz_capability_parity.py.

Follow-ups — flagged here, deliberately NOT filed as issues

  1. The base tags float — and that float IS this bug's recurrence vector. docker/{backend,scheduler}/Dockerfile are on python:3.13-slim while docker/base-image/Dockerfile pins -bookworm. Extend the bug: CI validates on Python 3.11 while every shipped image runs 3.13 #1891 guard to assert all three Dockerfiles agree on a codename.
  2. There is no smoke job for the scheduler image at all. backend-image-smoke.yml has no scheduler counterpart, so this PR's scheduler-only surface (docker/scheduler/*) has zero CI detector — WAVE 4's in-image run was the sole gate.
  3. backend-image-smoke is advisory, not required — a red run does not block merge.
  4. tests/requirements-test.txt floors apscheduler>=3.11.0, so CI resolves 3.11.3 while both images pin 3.11.0. The new parity test closes backend↔scheduler; the CI↔image skew remains.
  5. src/scheduler/pyproject.toml still floors apscheduler>=3.10.0 — inert for the image, diverges for local editable dev installs.
  6. tzdata pin asymmetry: backend tzdata==2026.3 vs scheduler tzdata>=2024.1 (each file keeps its own convention). Both resolve to 2026.3 today, but the parity test guards declaration presence, not version equality, so a future scheduler rebuild can drift.
  7. update_schedule has no access-first gate, unlike create's bug: valid webhook token intermittently returns 404 under concurrent load #1445 assert_agent_access (effectively unreachable — schedule ids are secrets.token_urlsafe(16)).
  8. Europe/Kyiv is missing from the UI timezone dropdown (SchedulesPanel.vue ships 7 hardcoded modern names, none of them aliases — which is why this is P3). Explicitly deferred by the issue to a theme-ui-ux follow-up.
  9. CI runs no canary invariant tests — tests/test_canary_invariants.py is outside tests/unit/ #2037 makes verify-local's integration stage structurally unusable on this host, and known-false-fails.txt cannot rescue it — that mechanism only --deselects and cannot survive a collection abort. Deserves a priority bump.
  10. tests/unit/test_1472_schedule_validation.py is still absent from tests/registry.json (pre-existing; the four new test_1823_* files are registered).

Merge note

This PR edits docs/memory/architecture.md. Sibling PR #1897 also edits it, inside a single ~4700-character line (L730). On conflict, hand-merge both sides' sentences into that one line — never --ours/--theirs, since each side is a whole paragraph of unrelated content.

No schema change (Redis/config only), so the dual-track Alembic / schema-parity question is moot. No src/frontend/ change, so no ui label and frontend-e2e is not engaged.

🤖 Generated with Claude Code

trinity-ability and others added 11 commits August 9, 2026 13:05
… resolve (#1823)

`docker/{backend,scheduler}/Dockerfile` are `FROM python:3.13-slim` with no
Debian codename pin. Docker Hub repointed that tag bookworm -> trixie, and
trixie split the IANA backward-compatibility links out of `tzdata` into a
separate `tzdata-legacy` package. Nobody changed a line: the images simply
stopped shipping `/usr/share/zoneinfo/Europe/Kiev`.

APScheduler's `astimezone()` re-resolves a pytz zone by IANA key through the
stdlib `zoneinfo`, so a schedule stored under any legacy alias then cannot
register — a raw 500 on create, and a silently non-firing row with a frozen
`next_run_at` in the scheduler.

Both images now install `tzdata-legacy` (the system database, complete) and
declare the `tzdata` wheel. The roles are layered, not redundant: `zoneinfo`
reads the system database first and falls back to the wheel only for keys the
system lacks, so with `tzdata-legacy` present the wheel is inert in production.
It is there because the recurrence vector is a floating base tag — an apt-only
fix is Debian-shaped and would not survive the next silent migration.

`tests/unit/test_1823_tz_capability_parity.py` is the durable half, the
#1891 / #1560 parity shape: bumping the packaging fixed today's divergence and
does nothing to stop the next image slim-down from dropping `tzdata-legacy`.
It also pins the base image's exemption to the reason that actually holds (the
agent tree registers no CronTrigger) rather than letting it be inherited, and
carries one runtime assertion — the one that goes red *inside* a mis-packaged
image, which is where this was found and the only place AC 1 is provable.

Verified non-vacuous by removing each declaration and observing the guard fail
(comments are stripped before matching — #1891's guard once shipped green
because the explanatory comment above a pin contained the package name).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…t binds (#1823)

#1472 established that the API must reject exactly what the scheduler would. It
mirrored the cron parser faithfully and the timezone resolver only halfway: it
copied `pytz.timezone(...)`, the scheduler's visible first step, and missed that
APScheduler's `astimezone()` re-resolves the zone by IANA key through the stdlib
`zoneinfo`. pytz bundles its own complete database, so it accepts every legacy
alias in every environment; `zoneinfo` depends on the system database, so it is
the strictly narrower — and actually binding — constraint.

`Europe/Kiev` therefore cleared `validate_timezone`, reached `CronTrigger`, and
raised `ZoneInfoNotFoundError`. That is a `KeyError` subclass, invisible to the
`except (ValueError, TypeError)` rescue, so it escaped as an unhandled 500.

Both validators now run ONE shared probe. `validate_timezone` gains a `zoneinfo`
check keyed on `pytz.timezone(tz).zone` — the exact string APScheduler hands to
`ZoneInfo` — and `validate_cron_expression` DELEGATES to it instead of
re-implementing the pytz probe. That delegation is the point, not a tidy-up: the
create route calls only `validate_cron_expression` while the update route calls
`validate_timezone`, so two mechanisms meant two timezone contracts on two
routes. Create inherits the probe it never had; the update path's silent-persist
(a bad zone written to the row and deferred to fire time) closes with it.

`validate_cron_expression` also catches `ZoneInfoNotFoundError` by name at the
`CronTrigger` call. Unreachable for any zone the probe agrees with, kept because
AC 2 wants "never a 500" for a future divergence the probe does not anticipate.
Named and NOT a bare `KeyError`: the widening would swallow a genuine dict-key
bug inside APScheduler and report it as "unknown timezone".

The unresolvable-but-pytz-known error is deliberately distinguishable from plain
"Unknown timezone" and names the missing tz data, because that case is an image
defect and saying so is how the next one is diagnosed in one read.

Tests: the Kiev fixture stays VALID (it is the accept branch end-to-end, and the
images now carry the capability); an AC-3 parity property pins both validators
against a real `CronTrigger` construction over canonical/alias/bogus/empty
zones; a structural test pins the delegation, since an equivalence test cannot
distinguish "delegates" from "happens to agree". The exception-conversion tests
are fault-injected and say so in their own scope note — 0 of 597 pytz zones are
unresolvable on a tz-complete runtime, so they prove our type mapping, never
anything about the environment.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…_job failure (#1823)

`_add_job`'s permanent arm caught `(pytz.exceptions.UnknownTimeZoneError,
ValueError)`. `zoneinfo.ZoneInfoNotFoundError` — what APScheduler's
`astimezone()` raises for a legacy alias the image's tz database lacks — is
neither: it is a `KeyError` subclass. So it fell through to the broad
`except Exception`, the TRANSIENT arm, and #1472's bounded-retry machinery was
defeated by exactly the failure it was built to bound:

  * never snapshotted into `_permanent_add_failures` -> retried every 60s forever
  * `logger.error(...(transient, will retry)...)` on every sync tick -> log flood
  * `next_run_at` frozen -> the "Next: Nd ago" symptom #1472 existed to remove
  * canary E-06 fires on the row every cycle

This is the fifth defect in the braid and is not named in the issue; it turned up
reproducing it. AC 5's "no silent fire-time failures" is really "no
retry-STORMING fire-time failures".

Added by NAME, never as a bare `KeyError`. This arm SUPPRESSES retries, so
widening it to the shared base class would have fixed #1823 while permanently
parking any schedule whose registration failed for a genuinely transient reason.
Both directions are pinned: a RuntimeError and a plain KeyError must both stay
transient.

The packaging half means no legacy alias reaches this arm any more; it still
matters for any zone a future runtime cannot resolve. The recovery path is
covered too — a row parked before the packaging fix registers and clears its own
flag once the image can resolve the zone, with no operator action.

Verified the two classification tests fail on the unfixed service.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…persist (#1823)

D4, verified live on the issue thread and the reason the fix had to land inside
`validate_timezone`: `PUT /api/agents/{name}/schedules/{id}` with
`timezone: "Europe/Kiev"` passed validation entirely, wrote the alias to the row,
and deferred the failure to scheduler registration — where the schedule simply
never fires and `next_run_at` freezes. Quieter than the create path's 500, and
worse for it.

Every case asserts on the WRITE not happening, not just on the status code: a
400 raised after a successful write would be worse than the old behaviour, not
better.

Three cases — a zone that exists nowhere (real input), the pytz-known but
unresolvable zone (fault-injected, since 0 of 597 pytz zones are unresolvable on
a tz-complete runtime), and a resolvable legacy alias going through, which is
#1823's accept branch reaching the route with no injection at all.

Verified the middle case fails against the pre-fix validator.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ne (#1823)

`update_schedule` validated an incoming cron against the literal "UTC". The
reasoning behind that — cron-field validity is timezone-independent — is correct
and is preserved: passing the effective zone changes no cron verdict. What the
hardcoded literal ALSO did was make a cron-only PUT (`updates.timezone is None`)
never look at the zone the row actually stores, so a row holding a zone the
scheduler cannot register was mutated and returned 200 OK while still never
firing. The API and the scheduler disagreeing is the exact contract #1472 exists
to hold, reached by a route AC 3's wording does not literally cover.

BEHAVIOUR CHANGE, deliberate, and the one regression in the #1823 work: in an
environment lacking the packaging fix, a cron-only PUT against such a row goes
200 -> 400. Two facts bound it — the row is ALREADY non-firing, so nothing that
works today breaks (the trade is "silently preserve a dead schedule" vs "say
which zone this runtime cannot resolve"), and once the packaging half lands the
branch is unreachable, since no pytz zone is unresolvable on a tz-complete
runtime.

Isolated in its own commit, with its tests in their own file, so it can be
dropped on its own if review disagrees with that trade.

The two pinning tests assert on the ARGUMENT handed to the validator, not on a
verdict: on a tz-complete runtime every zone validates identically, so a
verdict-based test would pass against the old literal and pin nothing. The
fault-injected 400 case fails exactly ONE zone rather than the whole database,
for the same reason — a total shim makes "UTC" unresolvable too and would fire
against the old code as well.

Verified all three fail against the unmodified router.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…s with (#1823)

SCOPE NOTE: not required for the #1823 fix to work. It is a coherence fix, and
it is a fleet-wide dependency-policy change riding on a timezone bug fix, so it
is isolated here to be dropped on its own.

`docker/backend/Dockerfile` pins `apscheduler==3.11.0`; this file floated
`>=3.10.0,<4.0.0`. The backend validates a schedule by constructing the same
`CronTrigger` this service will register — #1472's "reject exactly what the
scheduler would" — so a floor lets the validator and the executor resolve
DIFFERENT APScheduler versions and quietly re-opens the gap the contract exists
to close. `astimezone()`, which re-resolves a pytz zone through `zoneinfo`, is
the precise function whose behaviour caused this bug, so claiming a strict
same-parser contract while allowing version skew on that parser is incoherent.

The exact pin is the one deliberate exception to this file's floor convention,
because the constraint is equality with the backend rather than a minimum.

Nothing ties the two declarations together yet — that guard is a flagged
follow-up, not filed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`requirements/scheduling.md` line 568 asserted `# optional string, pytz zone`.
That was false, and it is the precise half-truth that produced the bug: pytz
bundles its own complete database and accepts every IANA backward-compatibility
alias in every environment, while APScheduler's `astimezone()` re-resolves the
zone through the stdlib `zoneinfo`, which depends on the system database. A
valid timezone is one BOTH resolvers accept.

Also records that aliases are SUPPORTED rather than normalized (the images ship
the backward links), that the two validators share one probe by delegation so
create and update cannot diverge, and that an unresolvable zone is a named 400
plus a bounded permanent scheduler failure — never a 500, never the 60s retry
storm that froze `next_run_at`. One row added to the ent#89 declared-schedules
error table for the same case.

`architecture.md` gains ONE sentence appended to the existing "Python version is
a single declaration, guarded (#1891)" paragraph: same "shipped image vs CI
runtime" divergence, one layer down (system packages instead of the
interpreter), and worth recording so a future image slim-down does not strip
`tzdata-legacy` believing it to be dead weight. Deliberately no new section, no
new table row, no reflow — that file is edited by sibling work in this run.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`scheduler-service.md`: the `_add_job` error-handling row listed only
`UnknownTimeZoneError`/`ValueError` in the permanent arm; adds
`zoneinfo.ZoneInfoNotFoundError` with why it must be named rather than caught as
its `KeyError` base (the arm suppresses retries). New revision-history entry
covering all three layers of the fix.

`scheduling.md`: the Dependencies block claimed to mirror
`docker/backend/Dockerfile` and had drifted on all three pins
(apscheduler 3.10.4 → 3.11.0, croniter 2.0.1 → 5.0.1, pytz 2024.1 → 2024.2);
corrected in the same pass as adding `tzdata`/`tzdata-legacy`, since adding one
true line beside three false ones is worse than leaving it alone. Records that
pytz is NOT the authoritative resolver and that the scheduler now pins the same
APScheduler as the backend.

No new flow document and no index row — the change modifies existing behaviour
rather than adding a feature. (`feature-flows.md` is 461 lines, over the skill's
400-line guidance; pre-existing, untouched here.)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Four new unit files from #1823. `/implement`'s checklist requires registration;
nothing in CI enforces it, which is precisely why it drifts (the pre-existing
`test_1472_schedule_validation.py` is not registered either — left alone here
rather than widened into a catalog cleanup).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…iness (#1823)

Review finding on this branch's own cron-only-`PUT` change (`ac2a7e8c`), raised
independently by a Gemini pass and confirmed reachable end to end.

`updates.timezone or schedule.timezone or "UTC"` treats an empty-string timezone
as "field absent". It is not: `ScheduleUpdateRequest.timezone` is a plain
`Optional[str]` with no validator, so `""` clears Pydantic, satisfies the
`is not None` gate on the very next branch, survives `model_dump(exclude_unset)`,
and is written through verbatim by `db.update_schedule` (its `allowed_fields`
loop has no falsy guard). `_add_job` then reads it as UTC
(`pytz.timezone(s.timezone) if s.timezone else pytz.UTC`) — so `""` is a SET
value meaning "scheduler default", and every layer agreed on that except the new
`or` chain, which fell back to the zone the write was removing.

Measured on the branch: a `PUT {"cron_expression": …, "timezone": ""}` handed the
validator `Europe/Kiev` while persisting `""`. Validator and persisted row
disagree, which is exactly the divergence class #1823 exists to close, one line
inside its own fix.

The harm is narrow but it inverts the trade `ac2a7e8c` is justified by. On a
runtime lacking the tz links, clearing a stale `Europe/Kiev` back to the default
IS the request that repairs the row — and it was rejected 400 against the zone
it was removing, leaving the schedule dead. "A named 400 beats a 200 that
silently preserves a dead schedule" only holds while the 400 is not itself
refusing the repair.

Resolve the post-write zone by presence, then apply the scheduler's own
empty->UTC rule. `None` -> stored, `""` -> UTC, explicit -> itself.

The create route's `getattr(schedule_data, "timezone", None) or "UTC"` is
deliberately left alone: with no middle fallback term, `"" or "UTC"` already
equals the effective value.

Two regression tests, both verified to fail against the pre-fix expression: one
pins the ARGUMENT handed to the validator (a verdict assertion cannot see this —
on a tz-complete runtime both zones validate identically), one pins that the
repairing PUT is applied rather than rejected.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#1823)

`ac644486` pinned `docker/scheduler/requirements.txt` to `APScheduler==3.11.0`,
matching the backend, and its own comment closes with: "Nothing ties these two
declarations together yet; keep them equal by hand when either moves."

That is precisely the shape `test_1823_tz_capability_parity.py` was created to
refuse — two hand-maintained declarations with nothing tying them together, the
#1891 lesson this issue is a second instance of. Shipping the pin without the
guard leaves the coherence argument resting on a comment.

Not hypothetical drift. As of today `>=3.10.0,<4.0.0` resolves to 3.11.3 on
PyPI while the backend pins 3.11.0, so a fresh build of both images right now
produces a validator and an executor running different copies of the parser the
#1472 contract is stated against — and `astimezone()`, which re-resolves a pytz
zone through `zoneinfo`, is the exact APScheduler function whose behaviour
caused #1823. The two images are also built from different caches at different
moments, so a floor does not merely risk divergence, it manufactures it.

Rule 5 asserts both declarations are exact `==` pins and equal, and says which
is which when they are not. Comments are stripped before matching (the file's
existing `_uncommented_lines`), so the pin's own explanatory comment block —
which names the version several times — cannot make the check vacuous. Verified
to fail when the scheduler declaration is reverted to its floor.

Deliberately scoped to the two images that construct a `CronTrigger`.
`src/scheduler/pyproject.toml` still floors at `>=3.10.0`; it is never
pip-installed by the image (`docker/scheduler/Dockerfile` installs from
requirements.txt only) so it governs nothing shipped, and pulling it in would
turn a targeted contract guard into a dependency-policy sweep.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@vybe
vybe marked this pull request as ready for review August 9, 2026 17:24

@vybe vybe 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.

Root cause reproduced in Docker rather than taken on trust:

python:3.13-slim  ->  Debian GNU/Linux 13 (trixie)
/usr/share/zoneinfo/Europe/Kiev  ->  No such file or directory
zoneinfo.ZoneInfo("Europe/Kiev")  ->  ZoneInfoNotFoundError
+ apt-get install tzdata-legacy  ->  Europe/Kiev, Europe/Kyiv, Asia/Calcutta, US/Eastern ALL RESOLVE

The tag carries no codename pin, so the image migrated bookworm->trixie with nobody changing a line. That is the entire bug, and this fixes it at the layer where it actually happens rather than papering over the 500.

Also verified:

  • APScheduler is pinned identically (3.11.0) in docker/backend/Dockerfile and docker/scheduler/requirements.txt — validator and executor can no longer resolve different versions, which is the whole point of that exception to the floor convention.
  • tzdata-legacy is in the backend and scheduler images and correctly ABSENT from the agent base image, which resolves no schedule timezones.
  • The parity guard bites: deleting tzdata-legacy from docker/backend/Dockerfile fails test_1823_tz_capability_parity on two assertions; restoring it goes green. That is what stops the next image-slimming pass from silently re-opening this.
  • 72 tests pass across the four #1823 files plus test_1472_schedule_validation; tests/registry.json updated.
  • merge-tree vs current dev: 0 conflicts.

@vybe
vybe merged commit f4e11a5 into dev Aug 9, 2026
24 of 25 checks passed
vybe pushed a commit that referenced this pull request Aug 9, 2026
Resolves the tests/registry.json conflict. Both sides were purely
additive — dev added the four #1823 timezone test files (#2071), this
branch adds the eight ent#14 registry test files — with no shared entry
modified and no entry removed on either side. Rebuilt from the git
stages rather than by splicing the markers: dev's file plus this
branch's eight new entries, 154 total, same indent=2 + trailing-newline
formatting.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants