Repository navigation
fix(skills): preserve binary skill assets as Buffer - #644
Conversation
Buffer.toString('utf-8') never throws on invalid sequences, so the previous try/catch always stored mangled strings. Use node:buffer isUtf8 so non-UTF-8 assets stay as Buffer for LoadSkillResourceTool.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@googlebot I signed it! |
|
Hi @nothariharan, We noticed that a few of the pre-checks are failing on this PR. Could you please resolve them? |
|
Hi @Varun-S10 — thanks for flagging this. I looked into the failing So this looks like a transient GitHub Actions / TLS checkout issue on the runner, not a failure in the skill-loader change. CLA, license-header, and cross-language checks on the same PR were already green, and I pushed an empty commit to re-trigger CI. Happy to re-run again if anything is still red after this pass. |
|
Follow-up: the empty commit re-queued the workflows, but @Varun-S10 if you could hit Approve and run workflows on the latest commit ( |
* fix(skills): preserve binary skill assets as Buffer
Buffer.toString('utf-8') never throws on invalid sequences, so the previous try/catch always stored mangled strings. Use node:buffer isUtf8 so non-UTF-8 assets stay as Buffer for LoadSkillResourceTool.
* chore: re-trigger Google CLA check
* chore: re-run CI after transient checkout SSL failure
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
loadDir/loadZipDirtried to keep binary skill resources asBufferviatry { data.toString('utf-8') } catch { data }. In Node.js,Buffer.prototype.toString('utf-8')never throws on invalid sequences — it substitutesU+FFFD— so the catch path was dead and binary assets were stored as corrupted strings. That breaksLoadSkillResourceTool'sBuffer.isBufferpath, which is what injects binary content asinlineData.Solution:
Decode with
isUtf8fromnode:buffer: valid UTF-8 becomes a string; everything else stays aBuffer. Shared helper used by both directory and zip loaders. Text skill resources are unchanged.Testing Plan
Unit Tests:
Summary:
npx vitest run --project unit:core core/test/skills/loader_test.ts— 49 passed (includes new coverage for PNG-signature bytes vialoadSkillFromDirandloadSkillFromZipBuffer).Also ran
npx eslint/npx prettier --checkon the touched files.Manual End-to-End (E2E) Tests:
assets/logo.pngcontaining real PNG bytes.loadSkillFromDir/loadSkillFromZipBuffer—resources.assets['logo.png']is aBuffer.load_skill_resourcefor that path returns the binary-detected status (not mangled UTF-8 text).Checklist
Additional context
Scoped to the skill loader decode path only. No packaging / CLI / unrelated changes.