Skip to content

fix(trace messages): send ids (plural) to match backend field name#88

Merged
Palash Shah (Palashio) merged 1 commit into
mainfrom
fix/trace-messages-ids-field
Apr 30, 2026
Merged

fix(trace messages): send ids (plural) to match backend field name#88
Palash Shah (Palashio) merged 1 commit into
mainfrom
fix/trace-messages-ids-field

Conversation

@Palashio
Copy link
Copy Markdown
Contributor

Summary

The `trace messages` command was sending `body["id"]` (singular) when filtering by trace IDs, but the backend `BatchTraceMessagesRequestBody` struct expects `"ids"` (plural, `json:"ids"`). This caused the trace ID filter to be silently dropped — the backend unmarshaled the field to its zero value (nil slice) and returned all traces instead of the requested ones.

In `internal/cmd/message.go`:
```go
// Before (broken): backend ignores this field, returns unfiltered results
body["id"] = ids

// After (fixed): matches json:"ids" on BatchTraceMessagesRequestBody.Ids
body["ids"] = ids
```

The backend `POST /v2/traces/messages` reads from `body.Ids` (JSON field `"ids"`). With the singular key, every `--trace-ids` invocation silently returned unfiltered results rather than the specified traces. This is the specific failure mode causing the issues-agent's phase 1b screener to get wrong data when it calls `langsmith trace messages --trace-ids`.

Test Plan

  • All existing `TestTraceMessages` unit tests pass
  • Built binary and verified against production with all four sandbox command patterns:
    • `trace messages --project --limit 3 --last-n-minutes 360` → returns traces correctly
    • `trace messages --project --trace-ids "id1,id2" --limit 5 --last-n-minutes 360` → returns exactly 2 traces matching the specified IDs
    • `LANGSMITH_PROJECT= trace messages --project --trace-ids "id" --limit 5` → returns exactly 1 trace
    • Verified trace_ids in response match the requested IDs exactly

Release Note

Fix `langsmith trace messages --trace-ids` filter being silently ignored due to wrong JSON field name (`id` → `ids`).

The backend BatchTraceMessagesRequestBody struct uses json:"ids" but the
CLI was sending body["id"] (singular), causing the trace ID filter to be
silently dropped by JSON unmarshaling — every --trace-ids call returned
unfiltered traces instead of the requested ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Palashio Palash Shah (Palashio) merged commit 6a5e88a into main Apr 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants