Skip to content

fix(D147): card an oversized file without reading it - #548

Merged
fazpu merged 2 commits into
mainfrom
fix/card-without-reading
Nov 7, 2026
Merged

fazpu merged 2 commits into
mainfrom
fix/card-without-reading

Conversation

@fazpu

@fazpu fazpu commented Nov 7, 2026

Copy link
Copy Markdown
Member

This closes a gap in the convert-by-reference seam (#545) that the UMC runtime's contract exposed: "for such a route, the convert stage must not read the raw object at all … it still applies its existing pre-read checks from metadata, including the reading limit, which cards instead of converting."

Gap. A non-PDF file over its family's reading limit is always carded (D138 §3, ConvertHandler._converter_for). The card holds only the size, format and file name, plus a Not read line. Even so, the convert stage read the whole object (read_bytes) only to take len(content), so a multi-GB upload was pulled into the worker's memory to produce a metadata card. This happened on self-host too.

Fix.

  • CardConverter.convert_unread(*, size, mime, hints) builds the identical card from the size alone. It refuses a size within the limit, which needs the bytes for image dimensions and archive listings.
  • ConvertHandler uses it for every oversized file, so the oversized object is never read, whichever route or store the deployment has.
  • CARD_CONVERTER_VERSION is unchanged, because the output is byte-identical (Rule 4: no re-keying).

Tests.

  • Unit: convert_unread(size) equals convert(content) for an oversized PDF, and a within-limit size is refused.
  • Integration (CI): a stored object over a patched 10-byte limit is converted to its card with zero read_bytes calls.

Checks. ruff, pyright (0), unit lane (3151 passed). DB tests run in CI only, because local Docker is down (shared VM disk).

🤖 Generated with Claude Code

https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm

fazpu and others added 2 commits November 7, 2026 12:12
The card of a file over its family's reading limit holds only metadata,
but the convert stage read the whole object to build it (len(content)).
CardConverter.convert_unread builds the identical card from the size and
MIME, and the convert stage uses it for every oversized file, so an
oversized object is never read, whatever route or store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
… OCR)

Codex round 1 minor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
@fazpu

fazpu commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

Codex review (gpt-6.1-sol, max effort)

VERDICT: APPROVE

  • Minor — decisions.md:7418: “A file over its family’s reading limit is carded” includes PDFs, which still fail before OCR under D139. Simplest fix: say “A non-PDF file…”.

No blocker or major findings. Card text, hints, warnings, and manifest match the original renderer. Within-limit reads, #545 URL routing, lane checkpoints and metering, and existing-representation replay remain correct. Rule 4 is satisfied: CARD_CONVERTER_VERSION and reuse keys stay unchanged.

Validation: 169 tests passed, 4 skipped; 4,032 full-result comparisons and 38 family/store checks passed using patched limits. CI unit, adapter integration, and contract smoke passed; worker and surface integration remain pending.

No files changed; no containers started.

Disposition (Claude)

The minor is accepted and fixed: D147 now says "A non-PDF file".

@fazpu
fazpu merged commit b13c3ae into main Nov 7, 2026
18 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.

1 participant