fix: preserve binary file content as base64 - #650
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📜 Recent review details🔇 Additional comments (3)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesFile Content Decoding
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to This localized change preserves binary file content while retaining existing UTF-8 behavior; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@index.ts`:
- Around line 2055-2063: Update the content guard in the parsedData decoding
block to verify that parsedData.content is a string rather than truthy, so empty
Base64 content is decoded and marked with encoding "utf8". Preserve the existing
lossless UTF-8 validation and assignment behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: be39e191-b063-4586-8dcf-a9fd923c07b6
📒 Files selected for processing (2)
index.tstest/test-get-file-contents.ts
📜 Review details
🧰 Additional context used
🪛 Betterleaks (1.7.3)
test/test-get-file-contents.ts
[high] 15-15: Identified a GitLab Personal Access Token, risking unauthorized access to GitLab repositories and codebase exposure.
(gitlab-pat)
🔇 Additional comments (1)
test/test-get-file-contents.ts (1)
1-125: LGTM!
Summary
base64encoding for non-UTF-8 repository filesutf8encoding for valid UTF-8 filesRoot cause
getFileContentsunconditionally decoded every GitLab Base64 payload withBuffer.toString("utf8"). Invalid UTF-8 bytes were replaced with the Unicode replacement character, so binary content could not be reconstructed from the response.The updated read path only returns decoded text when converting the bytes to UTF-8 and back is lossless. Otherwise, it leaves GitLab's original Base64 response unchanged.
Impact
Clients can now retrieve non-UTF-8 files without data corruption, while text-file behavior remains unchanged. This does not change the write path or public tool arguments.
Validation
npm.cmd run buildnode --import tsx/esm --test --experimental-test-isolation=none --test-concurrency=1 test/test-get-file-contents.ts test/streamable-http-concurrent-session.test.ts(4 tests passed)npx.cmd prettier --check test/test-get-file-contents.tsnpm.cmd run check:runtime-depsnpx.cmd tsx test/oauth-tests.tsCloses #648