From 23e5ee73f7ee95066cee2ba98e30981e3023b36c Mon Sep 17 00:00:00 2001 From: aiirvizionz Date: Mon, 13 Jul 2026 13:10:32 -0600 Subject: [PATCH] fix(social-pinterest): tolerate invalid created_at values --- packages/social/pinterest/src/index.test.ts | 31 +++++++++++++++++++++ packages/social/pinterest/src/index.ts | 4 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/social/pinterest/src/index.test.ts b/packages/social/pinterest/src/index.test.ts index 14118c9c..28875fa8 100644 --- a/packages/social/pinterest/src/index.test.ts +++ b/packages/social/pinterest/src/index.test.ts @@ -103,6 +103,37 @@ describe('social-pinterest posting', () => { }); }); + it('falls back to the current timestamp when Pinterest returns an invalid created_at', async () => { + vi.spyOn(globalThis, 'fetch').mockResolvedValue({ + ok: true, + status: 201, + json: async () => ({ + id: '654321654321654321', + created_at: 'not-a-date', + }), + } as Response); + + const ctx = { + ...fakeConnectContext({ PINTEREST_ACCESS_TOKEN: 'pinterest-token' }), + dryRun: false, + }; + + const result = await adapter.post(ctx as any, { + title: 'Launch visual', + body: 'Launch screenshot', + media: [{ file: 'https://cdn.example.com/launch.jpg', kind: 'image' }], + }, { + boardId: 'board_123', + }); + + expect(result).toMatchObject({ + id: '654321654321654321', + url: 'https://www.pinterest.com/pin/654321654321654321/', + platform: 'pinterest', + publishedAt: expect.any(String), + }); + }); + it('rejects local image paths because Pinterest image_url requires a URL', async () => { const ctx = { ...fakeConnectContext({ PINTEREST_ACCESS_TOKEN: 'pinterest-token' }), diff --git a/packages/social/pinterest/src/index.ts b/packages/social/pinterest/src/index.ts index b9638c25..6edebf1c 100644 --- a/packages/social/pinterest/src/index.ts +++ b/packages/social/pinterest/src/index.ts @@ -139,5 +139,7 @@ async function readPinterestResponse(res: Response): Promise