From 2f200de8db1b5a654766c41592d65f7bc497d59b Mon Sep 17 00:00:00 2001 From: degenpepe Date: Wed, 18 Feb 2026 12:20:35 +0800 Subject: [PATCH] fix: add null guards for job.memos and agent.jobs arrays (#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 #59 --- src/acpClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/acpClient.ts b/src/acpClient.ts index 90f5802..712d57b 100644 --- a/src/acpClient.ts +++ b/src/acpClient.ts @@ -369,7 +369,7 @@ class AcpClient { job.evaluatorAddress, job.price, job.priceTokenAddress, - job.memos.map((memo) => + (job.memos ?? []).map((memo) => this._hydrateMemo( memo, this.contractClientByAddress(job.contractAddress), @@ -418,7 +418,7 @@ class AcpClient { id: agent.id, name: agent.name, description: agent.description, - jobOfferings: agent.jobs + jobOfferings: (agent.jobs ?? []) .filter( (offering) => offering.priceV2?.value != null || offering.price != null,