LINE Webhook Verify Fails? Handle Empty events Correctly
LINE’s webhook URL verification sends an HTTP POST whose events array is empty. Your receiver should verify the signature and return 200 without trying to read a message or send a reply. A handler that assumes events[0] always exists can fail this test even when its message logic works. Conversely, passing Verify does not prove that real messages reach your queue or support inbox.
Key takeaways
- An authenticated
events: []request is a valid communication check, not a lost message. - Verify
x-line-signatureagainst the original body using the channel secret before interpreting the JSON. - Test connectivity and business processing separately; neither substitutes for the other.
- Keep LINE’s native webhook contract separate from UnifyPort’s normalized events.
What LINE’s Verify button actually sends
The official Verify webhook URL guide describes two ways to check communication: the webhook test API and the Verify button in LINE Developers Console. Both test whether LINE can communicate with your receiver. LINE instructs the receiver to return 200 for the request without an event.
The following is the body shape used in LINE’s signature-verification example, not a customer message:
{"destination":"U8e742f61d673b39c7fff3cecb7536ef0","events":[]}
There is no event object to contain a message, sender, or reply token. Do not construct a customer record from destination, invent a message identifier, or enqueue an automatic reply. Record the communication check separately from customer traffic if you need operational visibility.
Before changing the URL, confirm which component owns it. If several tools share the Official Account, use the multiple-tools webhook checklist to avoid moving traffic away from a working receiver while diagnosing a parser error.
Authenticate first, then allow an empty array
LINE’s signature verification guide specifies HMAC-SHA256 over the received body, using the channel secret as the key and Base64 encoding for the signature. This secret is not the channel access token used for outbound API calls.
Keep the incoming bytes intact. Parsing JSON and serializing it again can change whitespace or escaping and invalidate the signature. An empty events array is not a reason to skip authentication: an unauthenticated caller can send the same JSON shape.
This illustrative Node.js helper verifies and parses a native LINE request. rawBody must be the original Buffer supplied by your HTTP framework; channelSecret comes from server-side secret storage. It is not a complete server or queue implementation.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function readLineEvents(rawBody, signature, channelSecret) {
if (!Buffer.isBuffer(rawBody) || !channelSecret) {
throw new Error('Raw body and channel secret are required');
}
const expected = createHmac('sha256', channelSecret)
.update(rawBody)
.digest('base64');
const supplied = Buffer.from(signature ?? '', 'utf8');
const calculated = Buffer.from(expected, 'utf8');
if (supplied.length !== calculated.length ||
!timingSafeEqual(supplied, calculated)) {
return { status: 401 };
}
try {
const payload = JSON.parse(rawBody.toString('utf8'));
if (!payload || !Array.isArray(payload.events)) {
return { status: 400 };
}
return { status: 200, events: payload.events };
} catch {
return { status: 400 };
}
}
The 400 and 401 branches are this example’s defensive choices, not LINE API error codes. Integrate the result as follows:
- Pass the
x-line-signatureheader and untouched body to the helper. - Reject invalid requests without creating business work.
- If verification succeeds and
events.length === 0, return HTTP200immediately. - Otherwise, durably store the received events before acknowledging; process slow work asynchronously. Do not send
200merely because the helper returned that status if storage failed.
LINE recommends asynchronous processing. Your persistence and worker design remain application responsibilities. Iterate over the array rather than selecting only its first element.
Diagnose the boundary that failed
| Observation | Next investigation |
|---|---|
| No request reaches the application | Configured host and path, TLS, edge routing, and proxy logs |
| Signature verification fails | Correct channel secret, preserved raw bytes, and header forwarding |
| Verified empty request throws an exception | Unconditional access to the first event, message, or reply token |
| Application reports success but Verify fails | Status actually returned by the public edge and request timing |
| Verify passes but messages never reach the inbox | Real-event storage, event routing, and worker execution |
Do not rotate credentials or replace webhook ownership merely because a message-only handler rejects an empty array. If real events arrive but lack a reply token, that is another question: the LINE standby-mode guide explains responder ownership. An empty verification request has no event mode to inspect.
Prove connectivity and message handling separately
Use these proposed acceptance checks; they are not reported production results:
- A correctly signed empty request returns
200and creates no customer message or outbound task. - The same empty body with a missing or incorrect signature is rejected.
- A correctly signed non-empty request reaches durable storage before acknowledgement.
- After Verify succeeds, a controlled message sent to the intended Official Account appears in the expected inbox workflow.
- A storage failure does not get reported internally as completed processing just because the signature was valid.
Record only necessary diagnostics, such as signature-check outcome, event count, HTTP status, and observation time. Avoid routine logging of channel secrets, reply tokens, or customer message bodies.
Keep the UnifyPort receiver separate
UnifyPort’s unofficial interface connects a LINE account through the LINE authorization flow; it is not the Official Account’s native webhook test service.
Its webhook delivery contract uses X-Device-Signature: when signing_secret is configured, the signature is hex-encoded HMAC-SHA256 over X-Device-Timestamp, a dot, and the raw body. Its normalized envelope contains id, type, provider, account_id, occurred_at, and data, rather than LINE’s events array.
Use separate routes or explicit receiver configurations for these contracts. Never treat a missing native events field in a UnifyPort payload as an empty LINE verification request. Passing LINE Verify does not validate UnifyPort delivery, account authorization, or normalized message handling. Keep the official Messaging API path when the required identity is the LINE Official Account.
FAQ
Is events: [] an error?
Not in LINE’s webhook URL verification request. Authenticate it and return 200 without creating a message task. A missing or wrongly typed events field is not the same as an empty array.
Why does Verify fail when normal messages work?
A common implementation fault is assuming every request contains a first message event. Check the actual response and exception logs; transport or signature failures can also cause the test to fail.
Does successful verification prove my bot can reply?
No. It checks communication with the receiver, not storage, worker execution, reply eligibility, or a successful outbound API call.
Next step and sources
For an Official Account, run the LINE webhook URL check, then trace one real test message. For the independent UnifyPort integration, implement its documented webhook contract instead.
Official references checked on 2026-10-28:
Turn messaging integration into a stable product pipeline.
Start by sending through one API, then bring every inbound message back into your business system with standard events.