fix(agent-client): serialize fields[] projection as comma-separated string (PRD-437)#1622
Conversation
1 new issue
|
d7b155e to
b12a18c
Compare
|
Coverage Impact Unable to calculate total coverage change because base branch coverage was not found. Modified Files with Diff Coverage (1)
🛟 Help
|
…tring (PRD-437)
QuerySerializer.formatFields returned an array for the sparse fieldset
projection (e.g. { 'fields[Customer]': ['first_name','last_name','email'] }).
superagent serializes arrays via qs.stringify(obj, { indices: false }) as
repeated keys without brackets:
fields[Customer]=first_name&fields[Customer]=last_name&fields[Customer]=email
Rack-based (Ruby) agents collapse duplicate scalar keys to the LAST value, so
parse_projection (which does fields.split(',')) only ever saw the last field.
A getData/read-record reading first_name, last_name, email returned only email
(plus the primary key). The TS agent was unaffected by luck: it does
fields.toString().split(','), and Array.toString() rejoins with commas.
Join each projection into a single comma-separated value (JSON:API sparse
fieldset standard), which both Ruby (split) and Node agents parse correctly.
Also fixes the same class of issue for update-record and getRelatedData, which
share this serialization. Sibling of PRD-273 #8 (filter operator casing).
Update the mcp-server consumer tests that asserted the old array shape, and
tighten the field assertions to token-based matching (no substring matches).
fixes PRD-437
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b12a18c to
f73aeb3
Compare
| }); | ||
|
|
||
| it('should serialize fields as a single comma-separated value, not an array', () => { | ||
| // Regression (PRD-437): an array serializes as repeated params that Ruby agents collapse to one. |
There was a problem hiding this comment.
Claude Opus 4.8 — [Violates conventions] Comments must not reference PRD/Linear ticket numbers, including in tests. Drop the (PRD-437) token, e.g.:
// Regression: an array serializes as repeated params that Ruby agents collapse to one.
The source comment in query-serializer.ts correctly avoids the reference; this is the only ticket reference in the changed files.
Comments must not reference PRD/Linear ticket numbers, per project conventions and reviewer feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9e0434a
into
feat/prd-214-server-step-mapper

Problem
A
getData/read-recordstep run through the workflow-executor against a Ruby agent returns only the last requested field. Reproduced: readingfirst_name, last_name, emailreturns onlyemail. Works in browser mode; breaks only in Orchestrator mode (through the executor). TS agents are unaffected.Root cause
QuerySerializer.formatFieldsreturns an array for the sparse fieldset, e.g.{ 'fields[Customer]': ['first_name','last_name','email'] }. superagent serializes arrays viaqs.stringify(obj, { indices: false })as repeated keys without brackets:Rack-based (Ruby) agents collapse duplicate scalar keys to the last value, so
parse_projection(fields.split(','), expecting the JSON:API comma-separated string) only ever sees the last field → onlyemail+ the PK come back.fields[Customer]=first_name,last_name,email.fields.toString().split(','), andArray.toString()rejoins with commas. Ruby doesfields.split(',')→ no tolerance for an array.Fix
formatFieldsnow joins each projection into a single comma-separated string (fields[T]=a,b,c), the JSON:API sparse-fieldset standard, parsed correctly by both Ruby and Node agents. Also fixes the same class of issue forupdate-record/getRelatedData, which share this serialization.Sibling of PRD-273 #8 (filter operator casing). Distinct from PRD-432 (JWT casing).
Test plan
agent-client: 322/322 tests pass, including a new dedicated regression test assertingfields[users]is a comma-separated string, not an array.fields[Customer]=first_name,last_name,email→"...".split(",")=["first_name","last_name","email"].fixes PRD-437
🤖 Generated with Claude Code
Note
Serialize
fields[]query params as comma-separated strings in agent-clientRuby's Rack middleware collapses repeated query params, so
fields[users]=id&fields[users]=nameis not handled correctly.QuerySerializer.formatFieldsin query-serializer.ts now joins projection arrays into a single comma-separated string (e.g.fields[users]=id,name). Tests in both query-serializer.test.ts and server.test.ts are updated to assert string values instead of arrays.Changes since #1622 opened
QuerySerializer.serializetest [ff9c180]Macroscope summarized f73aeb3.