fix: parse MCP result payloads and drop place idempotency_key

Typed result structs replace empty envelopes. Equity place sends
ref_id only so live additionalProperties:false schemas accept the call.
This commit is contained in:
2026-09-01 14:18:39 -05:00
parent f52a19181d
commit a6bf8632ce
22 changed files with 2225 additions and 74 deletions
+49
View File
@@ -0,0 +1,49 @@
package wire_test
import (
"encoding/json"
"testing"
"s1d3sw1ped/robinhood-agentic-mcp/internal/wire"
)
func TestUnmarshalRows_objectAndArray(t *testing.T) {
t.Parallel()
type row struct {
ID string `json:"id"`
}
rows, next, err := wire.UnmarshalRows[row](json.RawMessage(`{"data":{"positions":[{"id":"a"}],"next_cursor":"c2"}}`), "positions", "results")
if err != nil {
t.Fatal(err)
}
if len(rows) != 1 || rows[0].ID != "a" || next != "c2" {
t.Fatalf("%+v %q", rows, next)
}
rows, next, err = wire.UnmarshalRows[row](json.RawMessage(`[{"id":"b"}]`), "positions")
if err != nil {
t.Fatal(err)
}
if len(rows) != 1 || rows[0].ID != "b" || next != "" {
t.Fatalf("%+v %q", rows, next)
}
rows, next, err = wire.UnmarshalRows[row](json.RawMessage(`{"results":{"id":"one"},"next":"https://x/?cursor=n3"}`), "positions", "results")
if err != nil {
t.Fatal(err)
}
if len(rows) != 1 || rows[0].ID != "one" || next != "n3" {
t.Fatalf("%+v %q", rows, next)
}
}
func TestCursor(t *testing.T) {
t.Parallel()
if wire.Cursor("https://x/y?cursor=abc", "") != "abc" {
t.Fatal("url")
}
if wire.Cursor("rawtok", "pref") != "pref" {
t.Fatal("pref")
}
if wire.Cursor("rawtok", "") != "rawtok" {
t.Fatal("bare")
}
}