fix(ocr): Test connection sent a corrupt probe PNG — Ollama answered HTTP 400 #38

Merged
daniel merged 1 commit from agent/fix-ocr-probe-png into main 2026-10-21 01:06:08 +02:00
Collaborator

Part of #14. This fixes the "Test connection → HTTP 400, invalid args" error the owner reported in #14, note 45419. The run that should have answered that note was OOMKilled.

Root cause

PROBE_PNG_BASE64 in src/transport/ocr.ts was malformed. Its IDAT chunk declared 11 bytes (…AAAAC0lE…) but held 13, so:

  • the chunk CRC never matched (computed 1fa2b2f0, expected 018084a9);
  • the zlib stream read as truncated (Error -5).

pngcheck reports CRC error in chunk IDAT. Ollama decodes the image and rejects the request with 400. Imports send real renders, which is why the owner's test sheet read fine through the same endpoint (18 of 18 lines answered).

Change

  • Replace the probe with a valid blank 64×64 grayscale PNG (98 bytes). 64 px also clears Qwen2.5-VL's 28 px patch, so a 1×1 image can't trip a minimum-size check either.
  • New test checkConnection > probes with a well-formed PNG a vision model can read. It takes the probe out of the real request body and checks the PNG signature, every chunk's CRC, that IHDR comes first and IEND last, that both sides are at least 28 px, and that IDAT inflates.

Verification

  • Red gate: the new test failed against the old constant (CRC mismatch) before the fix.
  • After the fix:
    • npx vitest run src/__tests__/ocr.test.ts: 11 passed.
    • Full suite: 839 passed, 0 failed.
    • npx tsc --noEmit -skipLibCheck: clean.
    • npx eslint on both files: clean.
  • prettier --check flags both files, but it already flags them on main, so this change doesn't introduce it.
  • Not verified against a live Ollama: this sandbox can't run a 6 GB vision model.

🤖 Generated with Claude Code

Part of #14. This fixes the "Test connection → HTTP 400, invalid args" error the owner reported in #14, note 45419. The run that should have answered that note was OOMKilled. ## Root cause `PROBE_PNG_BASE64` in `src/transport/ocr.ts` was malformed. Its IDAT chunk declared **11** bytes (`…AAAAC0lE…`) but held **13**, so: - the chunk CRC never matched (computed `1fa2b2f0`, expected `018084a9`); - the zlib stream read as truncated (`Error -5`). `pngcheck` reports `CRC error in chunk IDAT`. Ollama decodes the image and rejects the request with 400. Imports send real renders, which is why the owner's test sheet read fine through the same endpoint (18 of 18 lines answered). ## Change - Replace the probe with a valid blank **64×64** grayscale PNG (98 bytes). 64 px also clears Qwen2.5-VL's 28 px patch, so a 1×1 image can't trip a minimum-size check either. - New test `checkConnection > probes with a well-formed PNG a vision model can read`. It takes the probe out of the real request body and checks the PNG signature, every chunk's CRC, that IHDR comes first and IEND last, that both sides are at least 28 px, and that IDAT inflates. ## Verification - Red gate: the new test **failed** against the old constant (CRC mismatch) before the fix. - After the fix: - `npx vitest run src/__tests__/ocr.test.ts`: 11 passed. - Full suite: 839 passed, 0 failed. - `npx tsc --noEmit -skipLibCheck`: clean. - `npx eslint` on both files: clean. - `prettier --check` flags both files, but it already flags them on `main`, so this change doesn't introduce it. - Not verified against a live Ollama: this sandbox can't run a 6 GB vision model. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude self-assigned this 2026-10-21 01:03:47 +02:00
The 1×1 probe's IDAT chunk declared 11 bytes but held 13, so its CRC
never matched and the zlib stream read as truncated. Ollama refused it
with HTTP 400 while imports, which send real renders, read fine.

Replace it with a valid blank 64×64 PNG (above Qwen2.5-VL's 28 px patch)
and test that the probe parses: signature, chunk CRCs, inflatable IDAT.

Part of #14

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Collaborator

🤖 Agent has finished this run — session idle after turn 28. It resumes automatically on the next comment or event.

Last activity: round idle — updated 23:05:54 UTC

Last message:

The fix for the "Test connection → HTTP 400" error from #14 is done and I checked it myself. This run added no new code: the fix commit f31ca07 was already pushed, and the branch is up to date with main with no conflicts.

What I checked:

  • Tests: the full suite passes (839 passed, 1 skipped). Type-checking and lint are clean.
  • The new probe image: I decoded it on its own. It's a valid 64×64 grayscale PNG with correct checksums, and its image data unpacks to exactly the expected size.
  • The new test catches the bug: with the old probe image put back, it fails.
  • CI Node version: the test relies on a Node feature added in 22.2. The release workflow uses Node 22, so that's fine.

Not checked: I haven't tried it against a real Ollama, because this sandbox can't run the vision model. This branch also has no CI pipeline; the repo's only workflows are release and upstream-sync.

I didn't merge it. Agent merging is allowed, but the project requires an intent review before merge, and that hasn't run on this commit yet. Once it approves, the auto-merge sweep should merge it. I posted a summary on the MR and recorded what I verified.

🤖 **Agent has finished this run** — session idle after turn 28. It resumes automatically on the next comment or event. _Last activity: round idle — updated 23:05:54 UTC_ **Last message:** > The fix for the "Test connection → HTTP 400" error from #14 is done and I checked it myself. This run added no new code: the fix commit `f31ca07` was already pushed, and the branch is up to date with `main` with no conflicts. > > **What I checked:** > - **Tests:** the full suite passes (839 passed, 1 skipped). Type-checking and lint are clean. > - **The new probe image:** I decoded it on its own. It's a valid 64×64 grayscale PNG with correct checksums, and its image data unpacks to exactly the expected size. > - **The new test catches the bug:** with the old probe image put back, it fails. > - **CI Node version:** the test relies on a Node feature added in 22.2. The release workflow uses Node 22, so that's fine. > > **Not checked:** I haven't tried it against a real Ollama, because this sandbox can't run the vision model. This branch also has no CI pipeline; the repo's only workflows are release and upstream-sync. > > I didn't merge it. Agent merging is allowed, but the project requires an intent review before merge, and that hasn't run on this commit yet. Once it approves, the auto-merge sweep should merge it. I posted a summary on the MR and recorded what I verified.
Author
Collaborator

What changed

  • No new code this run. The fix in f31ca07 (valid 64×64 grayscale probe PNG, plus the probe-validity test) is already on the branch and up to date with main.
  • I re-checked it independently.

Verify

  • Full vitest suite: 839 passed, 1 skipped.
  • tsc --noEmit -skipLibCheck and eslint on both files: clean.
  • I decoded the new constant separately with Node's zlib:
    • all IHDR, IDAT and IEND CRCs are valid;
    • it is 64×64, 8-bit grayscale;
    • IDAT inflates to exactly 4160 bytes (64 rows × 65).
  • Red gate re-confirmed: with the old constant put back, the new test fails.
  • The test uses zlib.crc32, which needs Node ≥ 22.2. release.yml uses Node 22, so that's fine.
  • This branch has no CI pipeline; the repo only has release and upstream-sync workflows.
  • Still not tested against a live Ollama.

Follow-ups

  • None. Merge is left to the intent review and the auto-merge-on-green sweep.
## What changed - No new code this run. The fix in `f31ca07` (valid 64×64 grayscale probe PNG, plus the probe-validity test) is already on the branch and up to date with `main`. - I re-checked it independently. ## Verify - Full `vitest` suite: **839 passed**, 1 skipped. - `tsc --noEmit -skipLibCheck` and `eslint` on both files: clean. - I decoded the new constant separately with Node's zlib: - all IHDR, IDAT and IEND CRCs are valid; - it is 64×64, 8-bit grayscale; - IDAT inflates to exactly 4160 bytes (64 rows × 65). - Red gate re-confirmed: with the old constant put back, the new test fails. - The test uses `zlib.crc32`, which needs Node ≥ 22.2. `release.yml` uses Node 22, so that's fine. - This branch has no CI pipeline; the repo only has release and upstream-sync workflows. - Still not tested against a live Ollama. ## Follow-ups - None. Merge is left to the intent review and the auto-merge-on-green sweep.
daniel merged commit 742a84741e into main 2026-10-21 01:06:08 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
daniel/obsidian-remarkable-round-trip!38
No description provided.