Skip to content

[PR] fix: recognize legal JPEG marker fill during image billing - #6100

Closed
Afloat16 wants to merge 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-10_jpeg-marker-fill-bytes
Closed

Afloat16 wants to merge 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-10_jpeg-marker-fill-bytes

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The lightweight JPEG scanner interprets a repeated FF byte as a length-bearing marker and skips the real frame header. Legal marker fill makes a small valid JPEG receive the 16,384-token unknown-image fallback, inflating preflight budgets.

Changes

Skip FF marker fill before interpreting the marker, retaining the bounded scan and malformed/truncated fallback. JPEG T.81 B.1.1.2 and E.2.1 define this behavior: https://www.w3.org/Graphics/JPEG/itu-t81.pdf

Validation

  • Before: tests/issue767-pixel-billing.test.ts — 13 passed, 2 failed.
  • After: 15 passed, 0 failed. Real JPEGs, independent full decoding, actual pixel billing and fill-only/truncated controls are covered.
  • npm run typecheck — passed.
  • npm run build — passed.
  • Published fork tree 81c21d54358dd574d39e4d29d29c7aa29c098f51 exactly matches tested local commit f86c79e7788e14fca37b891499f19b509fb85897.

The full remote-suite verdict belongs to CI. #771/#1211/#1925/#3425 cover image billing, preprocessing and E2E tests, but not legal fill-byte runs in the lightweight dimension scanner. All 3,221 historical PRs were screened; independent of #6046–#6055.

Closes #6099

@ranxianglei ranxianglei changed the title fix: recognize legal JPEG marker fill during image billing [PR] fix: recognize legal JPEG marker fill during image billing Nov 10, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6439 (merged) — closing as superseded.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Confirmed — verified the landing before you close:

  • On master: commit 1c9c015146 "fix: recognize legal JPEG marker fill during image billing" (cherry-picked from your original commit 83689e9d), in via batch PR [PR] chore(batch): land 50 open Afloat16 fixes in one history-preserving batch #6439 (merge 873715d40a).
  • Code matches the PR description exactly: src/image-tokens.ts jpegDims() now skips 0xff marker fill (T.81 B.1.1.2) before interpreting the next marker; the bounded scan and malformed/truncated fallback are intact.
  • Tests landed with it (tests/issue767-pixel-billing.test.ts, +27 lines): APP0/SOF0 fill cases cross-checked against an independent full decode (Jimp), plus fill-only (300 KB of 0xff) and truncated-SOF negative controls that must still hit the fallback.
  • CI: the batch merge ran the full suite on the merged head, so the remote verdict is already in.

Labels: bug, scope/other, p3, superseded — edge-case billing inflation on JPEGs with marker fill; fix already landed via #6439, this PR superseded.

Close is yours to execute — agents can't close issues per policy.

八问

  1. 是什么问题:轻量 JPEG 尺寸扫描器把合法的 FF marker fill 误当成带长度段,跳过真实帧头,使小尺寸合法 JPEG 拿到 16384 token 的 unknown-image 兜底,虚增 preflight 预算。
  2. 什么原因导致的:扫描器定位 marker 时没有先跳过 T.81 B.1.1.2 允许的 FF fill 字节,把 fill 字节误判为 marker。
  3. 影响范围与严重程度:仅含 marker fill 的 JPEG(边缘条件);后果是图像 token 计费虚增(预算/体验),无可用性影响。p3。
  4. 怎么修复的:在解释 marker 之前先跳过 FF fill(一行 guard),保留有界扫描与 malformed/truncated 兜底;测试用独立全解码器交叉验证 + 负向对照钉住。
  5. 是否有回归问题:无。普通 marker 解析路径不变(测试显式钉住);fill-only/截断输入仍回退兜底(负向测试钉住)。
  6. 是否破坏缓存:不涉及(纯解析/计费逻辑,无缓存键)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:修复已随 #6439 合入 master,本 PR 按 superseded 结案,关闭操作由 owner 执行。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-triggered on this thread — nothing has changed since my confirmation above (floor 3), re-verified live just now:

No new PR or code work needed — the deliverable already landed. Leaving the thread as-is pending your close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legal JPEG marker fill causes pixel billing to fall back to 16K tokens

2 participants