fix(zapier): harden null-body handling and error messages
From an independent review pass:
- Guard search / get / add against a null or empty 2xx body (previously an
uncaught TypeError on .results / .status); return [] or an empty object.
- Stringify non-string API error detail so a thrown message never renders as
"[object Object]".
- Correct the Add sample to the default no-wait shape {event_id, status}.
- Add a regression unit test for the null-body path.
Verified: build + zapier validate + 16 tests (13 unit, 3 live E2E), plus a
live check of the v3-add to /v1/event poll cross-version path.
This commit is contained in:
@@ -124,6 +124,18 @@ describe('search / get array-shape enforcement (offline)', () => {
|
||||
} as any);
|
||||
expect(z.requests[0].params).toEqual({ page: 2, page_size: 10 });
|
||||
});
|
||||
|
||||
it('search and get_memories return [] on a null/empty body (no crash)', async () => {
|
||||
const zSearch = makeZ([{ data: null }]);
|
||||
const found = await searchMemories.operation.perform(zSearch, {
|
||||
inputData: { query: 'x', user_id: 'u1' },
|
||||
} as any);
|
||||
expect(found).toEqual([]);
|
||||
|
||||
const zGet = makeZ([{ data: null }]);
|
||||
const all = await getMemories.operation.perform(zGet, { inputData: { user_id: 'u1' } } as any);
|
||||
expect(all).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete_memory (offline)', () => {
|
||||
|
||||
Reference in New Issue
Block a user