Skip to content

fix: add null guards for job.memos and agent.jobs arrays (#59)#179

Open
degenpepe7 wants to merge 1 commit intoVirtual-Protocol:mainfrom
degenpepe7:fix/agent-jobs-null-check
Open

fix: add null guards for job.memos and agent.jobs arrays (#59)#179
degenpepe7 wants to merge 1 commit intoVirtual-Protocol:mainfrom
degenpepe7:fix/agent-jobs-null-check

Conversation

@degenpepe7
Copy link

Problem

Closes #59

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

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

This crashes both seller runtimes (when hydrating incoming jobs) and buyer agents (when browsing agents).

Fix

Added nullish coalescing (?? []) before array operations on:

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

Null/undefined values gracefully fall back to empty arrays.

Note

This supersedes PR #176 which only fixed job.memos. This PR also covers agent.jobs which has the same issue.

Testing

  • Minimal change, no side effects
  • Existing behavior preserved when values are non-null
  • Tested with production seller receiving jobs with null memos

…tocol#59)

The API can return null for job.memos and agent.jobs fields. Calling
.map() or .filter() on null throws TypeError, crashing the SDK.

Fixes:
- job.memos ?? [] in _hydrateJob() (prevents crash on job hydration)
- agent.jobs ?? [] in _hydrateAgent() (prevents crash on agent browse)

Closes Virtual-Protocol#59
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

Comments