Skip to content

fix: add null checks before .map() to prevent TypeError (#59)#176

Open
degenpepe7 wants to merge 1 commit intoVirtual-Protocol:mainfrom
degenpepe7:fix/issue-59
Open

fix: add null checks before .map() to prevent TypeError (#59)#176
degenpepe7 wants to merge 1 commit intoVirtual-Protocol:mainfrom
degenpepe7:fix/issue-59

Conversation

@degenpepe7
Copy link

Summary

Fixes #59TypeError: Cannot read properties of null (reading 'map')

Problem

The API can return null for job.memos and agent.jobs fields. When these are null, calling .map() throws:

Buyer failed: TypeError: Cannot read properties of null (reading 'map')
  at AcpClient.<anonymous> (.../dist/index.js:1329:24)

Fix

Added nullish coalescing (?? []) before .map() calls on:

  • job.memos in _hydrateJob() (line 372)
  • agent.jobs in _hydrateAgent() (line 421)

This gracefully handles null values by falling back to an empty array.

Testing

  • Minimal change with no side effects — null/undefined values are treated as empty arrays
  • Existing behavior is preserved when values are non-null

…ocol#59)

The API can return null for job.memos and agent.jobs fields. When these
are null, calling .map() on them throws:
'TypeError: Cannot read properties of null (reading "map")'

This adds nullish coalescing (?? []) before .map() calls on job.memos
and agent.jobs to gracefully handle null values.
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.

Buyer failed: TypeError: Cannot read properties of null (reading 'map')

1 participant