mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:11:26 +00:00
fix(line): return 200 for webhook verification requests without signature
LINE Platform sends POST {"events":[]} without an X-Line-Signature
header when the user clicks 'Verify' in the LINE Developers Console.
Both webhook.ts and monitor.ts rejected this with 400 'Missing
X-Line-Signature header', causing verification to fail.
Now detect the verification pattern (no signature + empty events array)
and return 200 OK immediately, while still requiring valid signatures
for all real webhook deliveries with non-empty events.
Fixes #16425
This commit is contained in:
committed by
Peter Steinberger
parent
3189430ad0
commit
4f2f641950
@@ -39,13 +39,24 @@ export function createLineWebhookMiddleware(
|
||||
return async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
||||
try {
|
||||
const signature = req.headers["x-line-signature"];
|
||||
const rawBody = readRawBody(req);
|
||||
|
||||
// LINE webhook verification sends POST {"events":[]} without a
|
||||
// signature header. Return 200 immediately so the LINE Developers
|
||||
// Console "Verify" button succeeds.
|
||||
if (!signature || typeof signature !== "string") {
|
||||
if (rawBody) {
|
||||
const body = parseWebhookBody(req, rawBody);
|
||||
if (body && Array.isArray(body.events) && body.events.length === 0) {
|
||||
logVerbose("line: webhook verification request (empty events, no signature) — 200 OK");
|
||||
res.status(200).json({ status: "ok" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
res.status(400).json({ error: "Missing X-Line-Signature header" });
|
||||
return;
|
||||
}
|
||||
|
||||
const rawBody = readRawBody(req);
|
||||
if (!rawBody) {
|
||||
res.status(400).json({ error: "Missing raw request body for signature verification" });
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user