fix: add payload validation guard in onWebhook handler
This commit is contained in:
@@ -729,15 +729,16 @@ const plugin = definePlugin({
|
||||
};
|
||||
|
||||
const { caseNumber, oldStatus, newStatus, companyId } = payload;
|
||||
|
||||
if (!caseNumber || !newStatus || !companyId) {
|
||||
pluginCtx.logger.warn("onWebhook: malformed payload", { caseNumber, newStatus, companyId });
|
||||
return;
|
||||
}
|
||||
|
||||
pluginCtx.logger.info(`Webhook: case ${caseNumber} ${oldStatus} → ${newStatus}`, {
|
||||
companyId,
|
||||
});
|
||||
|
||||
if (!companyId) {
|
||||
pluginCtx.logger.warn("onWebhook: missing companyId in payload", { caseNumber });
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the Paperclip issue linked to this case number by scanning plugin state.
|
||||
// State stores: issue.id → case_number (scopeKind=issue, stateKey=legal-case-number)
|
||||
const issues = await pluginCtx.issues.list({ companyId });
|
||||
|
||||
Reference in New Issue
Block a user