fix(agent-client): serialize fields[] projection as comma-separated string (PRD-437)#1622
Open
christophebrun-forest wants to merge 1 commit into
Conversation
1 new issue
|
…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>
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
|
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.

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.Macroscope summarized b12a18c.