Skip to content

fix: preserve supported bounds in ox_import_beat_schedules - #89

Merged
PhiLily merged 3 commits into
oxpull:mainfrom
ShivanshShukla:fix/import-beat-bounds
Sep 25, 2026
Merged

PhiLily merged 3 commits into
oxpull:mainfrom
ShivanshShukla:fix/import-beat-bounds

Conversation

@ShivanshShukla

Copy link
Copy Markdown
Contributor
  • What and why:
    Preserves supported start_time and expires bounds when importing schedules from django-celery-beat via ox_import_beat_schedules, without performing database writes.

    • Introspects django_celery_beat_periodictask for one_off, start_time, and expires columns, falling back gracefully if absent on older table versions.
    • Emits future starts as start_time=datetime.fromisoformat(...) and future expiries as end_time=datetime.fromisoformat(...) using repr-based quoting, omitting past starts.
    • Includes from datetime import datetime in Section 2 imports output.
    • Lists one-off rows (one-off tasks have no equivalent on a stored schedule), expired rows (it has expired), and expiries at or before a future start (its expiry is at or before its start time) under # Not translated, and why:.
    • Interprets naive cursor values using connection.timezone when USE_TZ=True, and preserves naive local times when USE_TZ=False.
    • Corrects the footer's enabled-state claim, retains the fixed-instant explanation, and warns that an expiry near the present can pass before application, invalidating generated calls at creation.
  • Tests: ran on SQLite and PostgreSQL (see CONTRIBUTING.md); new behavior is covered.

    • Updated make_beat_tables() fixture DDL using connection.data_types['DateTimeField'].
    • Updated Section 2 execution checks to include datetime in line-evaluation globals and verify preserved bounds.
    • Added test coverage for one-off task skips, expired task skips, expiry before future start skips, past start omission, future start/expiry bounds preservation, old table schemas missing columns, disabled task rows, and USE_TZ=True / USE_TZ=False timezone handling.
  • Changelog: entry added under ## [Unreleased] ### Fixed in CHANGELOG.md.

ShivanshShukla and others added 3 commits September 24, 2026 21:11
Quote every stored value printed by ox_import_beat_schedules with
ascii(), including skipped-row comments, task paths and cron fields.
Keep stored text on one physical line in generated settings and calls.

Set imported end_time one microsecond before beat's exclusive expiry,
stepping back on the UTC instant. Without USE_TZ, resolve expiry in
TIME_ZONE and print the adjusted end as local time. Stop on ambiguous
or nonexistent naive expiries and on datetime underflow.

Classify each row once against one import-time clock reading. List rows
whose adjusted end is at or before their start, or the import instant
when no start is given, with their own reason instead of a refused call.

Stop before printing output when database reads, decoding or date
conversion fail. Report one line naming the database, without catching
programming errors. Check whether date bounds are NULL so a non-NULL
bound decoded as None cannot silently lose its start or expiry.

List invalid JSON arguments and non-finite argument or interval numbers
with reasons. Keep NULL and empty arguments as no arguments, and retain
existing handling for valid JSON with unsupported shapes.

Check generated call fields using the printed imports and match reasons
to individual row lines. Exercise quoted values and supported calls as
a module and through InteractiveConsole. Cover older table layouts
without DROP COLUMN and clean up tables after partial setup failures.
Test read failures, selected connection zones, database aliases, exact
stored bounds and expiry dispatch across SQLite, PostgreSQL and MySQL,
including USE_TZ=False and clock changes.

Correct the application note for disabled schedules, elapsed bounds,
missed ticks, enabling schedules and partial application. Explain bound
handling with and without USE_TZ, differences from django-celery-beat
2.9.0 with time-zone support off, and the first-run behavior not
reproduced by the importer.

Add a Security changelog entry for the quoting bug (CWE-94) in versions
1.2.0-1.4.0. Describe the gap in protection when output is applied,
distinguish it from running the importer, and note that there are no
reports of it being used. Give upgrade, regeneration and inspection
guidance without implying that upgrading removes pasted code or that
inspection rules out prior execution.

Update the Fixed entry with untranslated rows, bound handling, read
errors, application guidance and review of previously imported
schedules. Regenerate docs/llms-full.txt from the changelog.

Closes oxpull#86
@PhiLily
PhiLily merged commit e6166e4 into oxpull:main Sep 25, 2026
34 checks passed
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