Repository navigation
fix(skills): refuse a partial skill body on dashboard read - #113
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
skill_get_content returned success after filling its buffer, so the dashboard editor saved that prefix and deleted the rest of the file. Reads that do not fit now fail, and GET /api/skills/:name answers 413 instead of a truncated 200. Co-authored-by: esadrianno <esadrianno@gmail.com>
This branch has not been deployed
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.
Dashboard skill edit could save a prefix and delete the rest of the file.
Bug and impact
GET /api/skills/:nameloaded the skill throughskill_get_contentinto a 32768-byte buffer. The read stopped when the buffer filled and still returned success. The dashboard copies that body into the editor andPUTs it back on Save, so a skill longer than the buffer lost its tail. A response that did not fit the 64 KiB HTTP buffer was also returned as HTTP 200 with a cut-off JSON body.fetch().json()then failed and the editor treated the content as empty, so Save wiped the file.Root cause
skill_get_contentcopied untilout_sizeand returned 0 without checking that the file was fully read.handle_skill_getthen printed that prefix, andjson_responseclamped any oversized JSON to the response buffer while leaving status 200.Fix
skill_get_contentreturns -2 when the file does not fit, including a short read.GET /api/skills/:namereturns 413 with the skill name and the limit instead of a truncated 200. A skill that fits is unchanged.Validation
make test_skilland./build/test_skillpass, including a new case that a short buffer returns -2 and an exact-fit buffer returns the full body.make GATEWAY=1 test_gateway_httpand./build/test_gateway_httppass. A 40000-byte skill returns HTTP 413 and the on-disk tail is still present. A small skill still returns HTTP 200 with its full text.