Skip to content

fix(net): join array fieldlist in net.retrieve so the documented usage works#477

Merged
wmathurin merged 2 commits into
forcedotcom:devfrom
wmathurin:fix/net-retrieve-array-fieldlist
Jul 7, 2026
Merged

fix(net): join array fieldlist in net.retrieve so the documented usage works#477
wmathurin merged 2 commits into
forcedotcom:devfrom
wmathurin:fix/net-retrieve-array-fieldlist

Conversation

@wmathurin

Copy link
Copy Markdown
Contributor

Problem

net.retrieve's public, typed signature accepts fieldlist: string[]:

retrieve('Contact', id, ['FirstName', 'LastName'], onSuccess, onError)

But the array was passed straight through to the native bridge as the fields query param. On Android, ArrayList.toString() produces fields=[FirstName, LastName]; on iOS, NSArray's description gives a similar bracketed form. Both are rejected by Salesforce with INVALID_FIELD / 400. The only form that actually worked — a pre-joined string — contradicted the TypeScript signature. The shared test suite only ever passed a pre-joined string, so the typed string[] path was never exercised.

Credit to @james-enperso for identifying the bug and the noEmit build discrepancy in PR #475.

Fix

Join the array before it crosses the bridge. A string is passed through unchanged for backward compatibility with callers that pre-join:

const fieldsValue = Array.isArray(fieldlist) ? fieldlist.join(",") : fieldlist;
const fields = fieldsValue ? { fields: fieldsValue } : null;

Build infrastructure fix

This PR also fixes the dist/ regeneration problem identified by @james-enperso.

The root issue: tsconfig.json extends @react-native/typescript-config which sets noEmit: true, so npm run build (tsc --build) type-checks only and never regenerates dist/. The committed dist/ was CommonJS output from a separate config, meaning any change to src/ required either hand-editing dist/ (fragile) or knowing about an undocumented release-time step.

This PR adds tsconfig.build.json — a config that extends tsconfig.json but overrides noEmit: false, module: commonjs, moduleResolution: node — so dist/ can be regenerated reproducibly by anyone with tsc --project tsconfig.build.json.

setversion.sh is updated to call npx tsc --project tsconfig.build.json instead of npm run build, so the release process now produces a correct dist/ automatically.

The dist/ regeneration in this commit also picks up TypeScript version drift (?? operator replacing verbose null-coalescing patterns, class field declarations at class body level) — all functionally identical.

Test plan

  • Verify net.retrieve('Contact', id, ['FirstName', 'LastName'], ...) works on iOS
  • Verify net.retrieve('Contact', id, ['FirstName', 'LastName'], ...) works on Android
  • Verify pre-joined string form net.retrieve('Contact', id, 'FirstName,LastName', ...) still works on both platforms
  • Run tsc --project tsconfig.build.json — should produce clean dist/ with no errors

🤖 Generated with Claude Code

…e works

The documented/typed signature passes fieldlist as string[], but the raw
array was forwarded straight to the native bridge as the `fields` query
param. On Android, ArrayList.toString() produces "[FirstName, LastName]";
on iOS, NSArray's description gives a similar bracketed form — both are
rejected by Salesforce with INVALID_FIELD / 400. The only working form
(a pre-joined string) contradicted the TypeScript signature.

Fix: join the array to a comma-separated string before the bridge crossing.
A string is passed through unchanged for backward compatibility with callers
that pre-join before passing.

Also adds tsconfig.build.json so dist/ can be regenerated reproducibly via
`tsc --project tsconfig.build.json` (the base tsconfig sets noEmit:true for
type-checking only). setversion.sh updated to use this config, closing the
gap where dist/ was previously hand-synced or relied on a separate
unreproducible release-time step. The dist/ regeneration in this commit also
picks up TypeScript version drift (null-coalescing rewrite, class field
declarations) — functionally identical changes.

Credit to @james-enperso for identifying the bug and the noEmit build
discrepancy in PR forcedotcom#475.
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
iOS ^18 Test Results35 ran35 ✅
TestResult
No test annotations available

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
iOS ^26 Test Results35 ran35 ✅
TestResult
No test annotations available

@wmathurin
wmathurin merged commit cbe5e53 into forcedotcom:dev Jul 7, 2026
10 of 12 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