Isolate per-file extraction failures in canvas and edX content syncs - #3753
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…d archives empty Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… tests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
load_content_files no-ops for non-course resources, so the randomized factory type made the test order-dependent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
content_files_loaded_actions fires search indexing gated by randomized resource fields; when the draw enables it, the eager task hits the nonexistent test opensearch and the resulting Retry is swallowed by process_course_archive's bare except, leaving the checksum unstamped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Pull request overview
Isolates Canvas and edX per-file extraction failures so healthy content continues syncing while failed records are retained.
Changes:
- Falls back from OCR failures to Tika.
- Tracks failed files and excludes them from cleanup.
- Adds checksum gating for partial and total failures.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
learning_resources/etl/utils.py |
Adds extraction fallback and failure tracking. |
learning_resources/etl/utils_test.py |
Tests extraction failure handling. |
learning_resources/etl/loaders.py |
Preserves failed content and problem files. |
learning_resources/etl/loaders_test.py |
Tests failed-file retention. |
learning_resources/etl/edx_shared.py |
Integrates failure tracking into edX syncs. |
learning_resources/etl/edx_shared_test.py |
Tests partial and total edX failures. |
learning_resources/etl/canvas.py |
Integrates failure retention and checksum gating. |
learning_resources/etl/canvas_test.py |
Tests Canvas retention and retry behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…d PDF Review fixes: a course whose only tutor problem file fails no longer blocks the checksum when content loaded (weekly re-extraction churn), and pdf_is_valid's internal pypdf log drops to warning so the outer process_olx_path report is the one Sentry event. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Closes #3750
Description (What does it do?)
One PDF that crashes the OCR converter currently aborts an entire canvas course sync before any contentfiles load — course
33842-7.06is stuck at 0 contentfiles on production because a single answer-key PDF crashes opendataloader (RasterFormatException). The same per-file loop (process_olx_path) serves edX archive ingestion and canvas tutor problem files, so any extractor exception kills those syncs the same way.This branch makes a failing file cost exactly that one file:
load_content_files' staleness/unpublish pass (canvas and edX), and the tutor problem orphan delete. New files that fail are simply absent this run — no empty placeholder rows.run.checksum, so a deterministic crash isn't re-downloaded and re-OCR'd weekly (failed files retry when the archive next changes, or via--overwrite). A total failure does not stamp, so the course retries next sync instead of looking legitimately empty. Same on edX: an all-failed archive is no longer mistaken for an empty one.One deliberate boundary: this covers extractors that blow up, not extractors that produce nothing. Files where Tika returns no response or empty content keep today's drop/unpublish semantics for all sources, same as main — they aren't recorded as failures.
No new database queries — the exclusions chain onto existing lazy querysets, and with no failures the generated SQL is identical to main.
How can this be tested?
Use the course from the issue — its current archive contains the PDF that crashes the converter, so it exercises the real failure path. With env pointed at the canvas course bucket (
CANVAS_COURSE_BUCKET_NAMEetc.) and OCR enabled:main, run./manage.py backpopulate_canvas_courses --canvas-ids 33842and watch it die on7.06_Fall2025_Exam1_answers.pdf(FileNotFoundErrorfor the converter output JSON) with the course left at 0 contentfiles.OCR extraction failed ... falling back to tikawarning for the answer-key PDF(s), the course going from 0 to ~158 contentfiles (the fallback text may be sparse), andrun.checksumset.--overwrite— it should logChecksums match ... skipping loadinstead of re-downloading and re-extracting.39194from the same incident) and sync it — no existing contentfiles should be deleted or flipped topublished=Falsebecause of extraction failures.🤖 Generated with Claude Code