@unito/integration-sdk
Version:
Integration SDK
20 lines (19 loc) • 893 B
TypeScript
/**
* Webhook payloads are provider-controlled untrusted strings. An unhandled
* `JSON.parse` throw crashes the handler, returns 500. The provider then
* retries delivery per its own (bounded) policy and eventually drops the
* event — webhook data is silently lost. Loss is undetectable: no error
* metric fires, the provider just stops sending.
*
* Wrap every `JSON.parse(...)` in a `try` block (or call it from inside a
* `catch` handler — already in error-handling territory).
*
* Detection covers two scopes:
* 1. Files matching /webhook.*\.ts$/i (filename signal)
* 2. Functions typed as Parse/AcknowledgeWebhook(s)Handler from the
* integration-sdk, regardless of filename (AST signal — catches
* handlers in `parseEvents.ts`, `eventDispatcher.ts`, etc.)
*/
import type { Rule } from 'eslint';
declare const rule: Rule.RuleModule;
export default rule;