Skip to content

fix: advance batch offset past unmigratable logs in auditlogmigratejson - #838

Open
Sanjays2402 wants to merge 1 commit into
jazzband:masterfrom
Sanjays2402:fix/auditlogmigratejson-batch-offset
Open

fix: advance batch offset past unmigratable logs in auditlogmigratejson#838
Sanjays2402 wants to merge 1 commit into
jazzband:masterfrom
Sanjays2402:fix/auditlogmigratejson-batch-offset

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #667

Log entries whose changes_text is not valid JSON are reported as errors but stay in the get_logs() queryset, and each batch re-fetched the same entries from the top of that queryset. Once a batch filled up with unconvertible entries the migration stopped making progress, so everything behind them was never migrated (the symptom in the issue: repeated runs report a large remaining count).

The batch window now advances by the number of entries that failed conversion, and the queryset is ordered by primary key so that offset is stable across batches.

The new test_using_django_batched_skips_unmigratable_logs puts an unmigratable entry ahead of a migratable one; it fails on master (AssertionError: unexpectedly None) and passes with the fix.

Log entries whose changes_text is not valid JSON are reported as errors
but stay in the get_logs() queryset. Every batch re-fetched the same
unconvertible entries from the top of the queryset, so once a batch was
filled with them the migration made no further progress and the entries
behind them were never migrated.

The batch window now advances by the number of entries that failed
conversion, and the queryset is explicitly ordered by primary key so the
offset is stable across batches.

Adds a regression test that places an unmigratable entry ahead of a
migratable one and asserts the latter is still migrated.
@2ykwang
2ykwang self-requested a review July 25, 2026 08:52
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.34%. Comparing base (da85ac4) to head (08cc8e4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #838   +/-   ##
=======================================
  Coverage   96.33%   96.34%           
=======================================
  Files          35       35           
  Lines        1256     1259    +3     
=======================================
+ Hits         1210     1213    +3     
  Misses         46       46           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Migration Command Fails to Update All LogEntry Objects Due to Batch Processing Issue

1 participant