fix(documenso): skip legacy v1 document IDs in the v2 status poller
The signature-poll worker fetched every sent/partially_signed document via
GET /api/v2/envelope/{id}. Pre-cutover documents carry a bare numeric
documenso_id (e.g. "46"), which the v2 envelope endpoint rejects with 400
"Invalid envelope ID" — ~36 errors/hour on prod from 3 abandoned June-3 EOIs.
Skip documents whose documenso_id isn't an `envelope_xxx` string when the
port is on the v2 API (v1-API ports keep polling numeric ids). New v2 signing
is unaffected. Pure isPollableDocumensoId() helper, unit-tested.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L2qc3xZTfif7N4Wq3QDa8X
This commit is contained in:
21
tests/unit/documenso-poll.test.ts
Normal file
21
tests/unit/documenso-poll.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { isPollableDocumensoId } from '@/jobs/processors/documenso-poll';
|
||||
|
||||
describe('isPollableDocumensoId', () => {
|
||||
it('skips legacy v1 numeric ids when the port is on the v2 API', () => {
|
||||
// Real prod offenders: abandoned June-3 v1 EOIs whose documenso_id is "46"/"85"/"88".
|
||||
// The v2 /api/v2/envelope/{id} endpoint rejects bare numerics ("Invalid envelope ID").
|
||||
expect(isPollableDocumensoId('46', 'v2')).toBe(false);
|
||||
expect(isPollableDocumensoId('125', 'v2')).toBe(false);
|
||||
});
|
||||
|
||||
it('polls real v2 envelope ids on the v2 API', () => {
|
||||
expect(isPollableDocumensoId('envelope_ydshkombscbhfnfd', 'v2')).toBe(true);
|
||||
});
|
||||
|
||||
it('still polls numeric ids for a port that is on the v1 API', () => {
|
||||
expect(isPollableDocumensoId('46', 'v1')).toBe(true);
|
||||
expect(isPollableDocumensoId('envelope_abc', 'v1')).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user