fix(mcp): name raw argument bytes when brain_edit refuses an empty old_str
hyperguild#115: a session reported "old_str is empty" with old_str that was never empty on their end. Server-side round-trip re-verified clean (fresh brain_edit call, real content, succeeds) — the code path itself isn't broken, but its error left no way to tell "client sent empty" apart from "something between the client and here lost the field" without a second investigation. The refusal now names the raw argument byte count. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -70,6 +70,29 @@ func TestBrainReadAndEdit_RoundTripThroughJSONRPC(t *testing.T) {
|
||||
"only the matched bytes may change")
|
||||
}
|
||||
|
||||
func TestBrainEdit_EmptyOldStrErrorNamesRawArgumentBytes(t *testing.T) {
|
||||
// hyperguild#115: a session reported "old_str is empty" with an old_str
|
||||
// that, on their end, was never empty. The server-side path was
|
||||
// unreachable to reproduce (verified separately: a fresh brain_edit call
|
||||
// with real content round-trips cleanly), which points at something
|
||||
// between a specific client and this call losing the field. The fix this
|
||||
// issue actually asked for isn't a behavior change — old_str=="" must
|
||||
// still refuse — it's that the refusal should say how many raw argument
|
||||
// bytes it received, so "client sent empty" is distinguishable from
|
||||
// "server received empty after some hop lost it" without a second
|
||||
// session's worth of guessing.
|
||||
dir := newBrainRepo(t)
|
||||
srv := mcp.NewServer(dir, nil, nil, nil)
|
||||
|
||||
resp := call(t, srv, "brain_edit", map[string]any{
|
||||
"path": "wiki/homelab/facts/n.md", "old_str": "", "new_str": "BETA",
|
||||
})
|
||||
errMsg, ok := resp["error"].(map[string]any)["message"].(string)
|
||||
require.True(t, ok, "%v", resp)
|
||||
assert.Contains(t, errMsg, "old_str is empty")
|
||||
assert.Contains(t, errMsg, "raw arguments were", "%v", errMsg)
|
||||
}
|
||||
|
||||
func TestBrainEdit_RefusesGovernanceFilesFromTheModelFacingTool(t *testing.T) {
|
||||
dir := newBrainRepo(t)
|
||||
srv := mcp.NewServer(dir, nil, nil, nil)
|
||||
|
||||
Reference in New Issue
Block a user