What we found
Webhooks.constructEvent verifies the signature, then parseVerifiedPayload casts the body with as unknown as EventResponse and hands it to deserializeEvent. Nothing checks the shape between the two steps.
Effect
The signature proves the origin of the payload, not its shape. A field that changes type, or a field that is absent, becomes a runtime error deep inside application code, and the error names neither the webhook nor the field. Consumers who want a safe boundary re-implement per-event guards that duplicate knowledge the SDK already holds in its interfaces and serializers.
Request
Validate the deserialized event against its declared shape and throw a named error that states the event type and the failing field. A schema library is not required; a small guard per event type is enough, and the generated interfaces already describe the expected shape.
Related
#1319 described the confusion between the camelCase Event type and the snake_case wire payload. A validation step at the boundary makes that boundary explicit.
What we found
Webhooks.constructEventverifies the signature, thenparseVerifiedPayloadcasts the body withas unknown as EventResponseand hands it todeserializeEvent. Nothing checks the shape between the two steps.Effect
The signature proves the origin of the payload, not its shape. A field that changes type, or a field that is absent, becomes a runtime error deep inside application code, and the error names neither the webhook nor the field. Consumers who want a safe boundary re-implement per-event guards that duplicate knowledge the SDK already holds in its interfaces and serializers.
Request
Validate the deserialized event against its declared shape and throw a named error that states the event type and the failing field. A schema library is not required; a small guard per event type is enough, and the generated interfaces already describe the expected shape.
Related
#1319 described the confusion between the camelCase
Eventtype and the snake_case wire payload. A validation step at the boundary makes that boundary explicit.