fix: skip presigning asset URLs for missing chunk artifacts - #249
Open
gdccyuen wants to merge 1 commit into
Open
fix: skip presigning asset URLs for missing chunk artifacts#249gdccyuen wants to merge 1 commit into
gdccyuen wants to merge 1 commit into
Conversation
_document_chunk_asset_url presigned an asset URL for every image/table chunk with a file_path, with no existence check, so chunks whose raw artifact is absent from the results bucket (e.g. old jobs with dropped files) exposed dangling 404 URLs to clients. Verify the artifact exists before presigning; return null when missing and fail closed on storage errors, so clients never receive URLs that 404. - unit tests: URL generated when file exists; null when missing; null on verification errors and for non-media chunks / include_asset_urls=false - contract tests: seed real raw assets (tables/table-1.html, images/figure-1.png) so URL assertions check actual objects; fakes gain verify_raw_exists
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
_document_chunk_asset_urlpresigned an asset URL for every image/table chunk with afile_path, without checking the object exists. Chunks whose raw artifact is absent from the results bucket (e.g. older jobs whose files were dropped or never uploaded) exposed dangling 404 URLs to clients — the notebook's chunk enrichment would fetch them and fail.Change
JobResultStorage.verify_raw_exists) before presigning.nullwhen the file is missing; fail closed on storage errors (never hand out a URL that can 404).Tests
test_document_chunk_asset_url.py): URL generated when file exists;nullwhen missing;nullon verification error and for non-media chunks /include_asset_urls=false.tables/table-1.html,images/figure-1.png) so the URL assertions check actual objects; result-storage fakes gainverify_raw_exists.Verified: ruff + pyright clean; 50 API unit/contract tests pass.