Skip to content

Fix large-file ingest (500 → works) + SDK max_file_size guard#113

Merged
Hazzng merged 3 commits into
mainfrom
feature/skill-improvement
Jun 4, 2026
Merged

Fix large-file ingest (500 → works) + SDK max_file_size guard#113
Hazzng merged 3 commits into
mainfrom
feature/skill-improvement

Conversation

@Hazzng

@Hazzng Hazzng commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes large-file ingest (which returned 500 for files larger than ~750 KB) and adds a client-side per-file size guard to the Python SDK. Verified end-to-end by ingesting the full just-bash repo (1603 files / 20.6 MB, including two ~4 MB binaries) byte-exact.

What changed

Server — sql-fs-api (fix, patch)

  • isValidBase64 ran a structural regex whose (?:[A-Za-z0-9+/]{4})* quantifier overflowed V8's call stack (RangeError: Maximum call stack size exceeded) on base64 strings beyond ~1 MB — so ingesting any file over ~750 KB failed with 500 INTERNAL_ERROR during request validation, before any DB work. The regex is now skipped for strings over 1 MB, relying on the native canonical round-trip check (Buffer.from(s, "base64").toString("base64") === s), which never overflows.
  • Bumped just-bash ^2.14.5^3.0.1. The 3.0.0 stdin byte/utf8 overhaul makes cat, pipes (|), append (>>), and concatenation byte-correct on binary content (2.14.5 re-encoded binary as UTF-8). FS-level ops (cp/mv/rm) and content-addressable storage were always byte-correct.

Python SDK — sql-fs-sdk 0.2.5 → 0.3.0 (feat)

  • New Client(max_file_size=...) (default 64 MiB) enforces a per-file ceiling on every write path (ingest_files, fs.write, fs.write_files) before any content is base64-encoded or sent. Oversized files raise ValidationError(code="EFILE_TOO_LARGE") (with status=None) naming each offending path/size. Threaded to every Sandbox; set max_file_size=0 to disable.

Docs

  • Updated the api and py-sdk skills: real ingest size limits, the large-file fix, and the new max_file_size knob / EFILE_TOO_LARGE error.

Testing

  • Ingested the full just-bash folder (1603 files, 20.6 MB) → all stored, md5sum matches for sampled files including the two ~4 MB binaries.
  • Single-file ingest verified byte-exact at 16 / 32 / 64 / 128 MB.
  • max_file_size: rejects 65 MB, accepts 64 MB, honors custom limits, 0 disables.
  • pnpm typecheck + pre-commit lint/typecheck hooks pass.

Notes

  • The just-bash bump is intentionally without a changeset — it rides into the next release without its own changelog entry.
  • Known residual (upstream, not yet fixed in just-bash 3.0.1): head -c N / tail -c N reading from a file argument still decode binary as UTF-8 and mis-count bytes (piping in, cat bin | head -c N, is byte-clean). Tracked separately.

Hazzng added 2 commits June 5, 2026 00:31
isValidBase64 ran a regex whose '(?:...){4})*' quantifier overflowed V8's call stack on base64 strings >~1MB, so ingesting files >~750KB returned 500 during validation, before any DB work. Skip the regex for strings over 1MB and rely on the native canonical round-trip check (Buffer.from(s,'base64').toString('base64') === s), which never overflows.

Also bump just-bash ^2.14.5 -> ^3.0.1 (3.0.0 stdin byte/utf8 overhaul makes cat/pipes/append/concat byte-correct on binary) and document real ingest size limits in the api skill.
Client(max_file_size=...) (default 64 MiB) rejects oversized files on every write path (ingest_files, fs.write, fs.write_files) BEFORE any base64 encoding or network I/O, raising ValidationError(code='EFILE_TOO_LARGE') naming each offending path/size. Threaded to every Sandbox the client creates or attaches; set 0 to disable.

Bumps the Python SDK to 0.3.0 and updates the py-sdk skill docs (client/errors/sandbox/SKILL).
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Hazzng, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 36 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e608efcc-f81a-45f6-bc49-343f532e2be6

📥 Commits

Reviewing files that changed from the base of the PR and between cced86f and f1fb686.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • .changeset/fix-ingest-base64-stack-overflow.md
  • README.md
  • clients/python/CHANGELOG.md
  • clients/python/README.md
  • clients/python/pyproject.toml
  • clients/python/src/sqlfs/_version.py
  • clients/python/src/sqlfs/client.py
  • clients/python/src/sqlfs/sandbox.py
  • package.json
  • plugins/sql-fs/skills/api/ref/endpoints.md
  • plugins/sql-fs/skills/py-sdk/SKILL.md
  • plugins/sql-fs/skills/py-sdk/ref/client.md
  • plugins/sql-fs/skills/py-sdk/ref/errors.md
  • plugins/sql-fs/skills/py-sdk/ref/sandbox.md
  • src/api/ingest-validation.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/skill-improvement

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Hazzng

Hazzng commented Jun 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Root README: add MAX_REQUEST_BODY_BYTES, MAX_INGEST_BYTES, MAX_INGEST_FILES, MAX_INGEST_PATHS_CONCURRENCY to the env-var table (the ceilings governing ingest).

SDK README: document Client(max_file_size=...) (default 64 MiB, client-side, 0 disables) and the client-side EFILE_TOO_LARGE ValidationError.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Hazzng Hazzng merged commit dba20f6 into main Jun 4, 2026
17 checks passed
@Hazzng Hazzng deleted the feature/skill-improvement branch June 4, 2026 15:13
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