From 79109e163b02f86560825f6789edb30f0dc2b3a7 Mon Sep 17 00:00:00 2001 From: degenpepe Date: Sun, 15 Feb 2026 18:38:55 +0800 Subject: [PATCH] fix: add null checks before .map() to prevent TypeError (#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. --- src/acpClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/acpClient.ts b/src/acpClient.ts index bce7dfc..3e88b3f 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,