Skip to content

fix: skip presigning asset URLs for missing chunk artifacts - #249

Open
gdccyuen wants to merge 1 commit into
Ontos-AI:mainfrom
gdccyuen:feat/gdccyuen/table-html-assets
Open

fix: skip presigning asset URLs for missing chunk artifacts#249
gdccyuen wants to merge 1 commit into
Ontos-AI:mainfrom
gdccyuen:feat/gdccyuen/table-html-assets

Conversation

@gdccyuen

@gdccyuen gdccyuen commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What

_document_chunk_asset_url presigned an asset URL for every image/table chunk with a file_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

  • Verify the artifact exists (JobResultStorage.verify_raw_exists) before presigning.
  • Return null when the file is missing; fail closed on storage errors (never hand out a URL that can 404).
  • Missing-file URLs are now skipped with a warning log instead of presigned blindly.

Tests

  • New unit tests (test_document_chunk_asset_url.py): URL generated when file exists; null when missing; null on verification error and for non-media chunks / include_asset_urls=false.
  • Contract tests: seed real raw assets (tables/table-1.html, images/figure-1.png) so the URL assertions check actual objects; result-storage fakes gain verify_raw_exists.

Verified: ruff + pyright clean; 50 API unit/contract tests pass.

_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
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.

1 participant