Harden get_pad_code schema, truncation, and environments - #212
Merged
Conversation
adamtheturtle
force-pushed
the
agent/fix-pad-code-batch
branch
from
August 20, 2026 15:24
ef39740 to
6c3c3b3
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 196cdff. Configure here.
adamtheturtle
enabled auto-merge
August 20, 2026 15:34
Keep truncation markers inside the UTF-8 byte budget, document the default per-file cap, surface malformed environment and file schema problems as incomplete payloads, and verify environment ownership. Co-authored-by: Cursor <cursoragent@cursor.com>
Split environment file assembly into a shared state object so body length and parameter-count limits stay within CI. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
adamtheturtle
force-pushed
the
agent/fix-pad-code-batch
branch
from
August 20, 2026 15:38
86ec1ac to
0d33126
Compare
adamtheturtle
added a commit
that referenced
this pull request
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
max_file_charsas a UTF-8 byte budget with a default of 200,000 and keep truncation markers inside that budget.pad_environment_ids, missing/null nonbinary contents, and non-booleanbinaryflags as incomplete schema errors.Fixes #120
Fixes #121
Fixes #122
Fixes #123
Fixes #124
Fixes #125
Fixes #126
Fixes #127
Fixes #128
Fixes #129
Fixes #130
Fixes #131
Fixes #132
Fixes #133
Fixes #134
Fixes #175
Fixes #176
Fixes #177
Fixes #178
Fixes #179
Fixes #180
Test plan
swift test --filter PadCodeTestsNote
Medium Risk
Touches untrusted remote pad/environment payloads: path sanitization, ownership checks, and output size bounds. Logic is defensive and well-tested, but mistakes here could leak files across pads or blow MCP context.
Overview
Hardens
get_pad_codeso malformed API data cannot silently produce unbounded, incomplete, or cross-pad file lists.Truncation and budgets:
max_file_charsis documented as a UTF-8 byte cap (default 200k). The truncation marker now counts toward that budget. Binary files are kept after the text budget is exhausted.Schema completeness: Malformed
pad_environment_ids, missing/null nonbinary contents, non-booleanbinaryflags, missingfile_contents, and unsafe paths/languages mark the payloadincompletewithschema_errors. Environment responses must match the requested id and pad (pad_id).Sanitization and fetch: Paths reject trailing slashes and empty components; flattened/suffixed names stay within path byte limits. Display fields strip Unicode format controls. Language→extension maps cover creatable pad languages. Environment fetches parse and drop each concurrent batch before the next so raw bodies are not retained all at once.
Reviewed by Cursor Bugbot for commit 0d33126. Bugbot is set up for automated code reviews on this repo. Configure here.