fix(aws-lambda): accept lowercased secret-token header for HTTP API#900
Merged
KnorpelSenf merged 1 commit intoApr 20, 2026
Merged
Conversation
The awsLambda and awsLambdaAsync adapters read the X-Telegram-Bot-Api-Secret-Token header with a case-sensitive lookup against the title-case constant. This works for API Gateway REST APIs (payload format 1.0), which preserve the original client header case, but fails for API Gateway HTTP APIs (payload 1.0 or 2.0), which lowercase all inbound header names. Users on HTTP API with a configured secretToken therefore had every update rejected 401. AWS documents the HTTP API lowercasing behaviour in the payload format structure section: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html Falls back to the lowercase constant so both integration types work without regressing REST API users. Parallels PR grammyjs#896 for the Azure adapter.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #900 +/- ##
==========================================
- Coverage 45.52% 44.17% -1.36%
==========================================
Files 19 19
Lines 5520 6694 +1174
Branches 360 463 +103
==========================================
+ Hits 2513 2957 +444
- Misses 3003 3651 +648
- Partials 4 86 +82 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Why does REST API 1.0 still work after this change, given that there is now a mismatch in casing? |
KnorpelSenf
approved these changes
Apr 20, 2026
Member
KnorpelSenf
left a comment
There was a problem hiding this comment.
Ah hold on, looking at the diff helped, nevermind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #896. The
awsLambdaandawsLambdaAsyncadapters insrc/convenience/frameworks.tsread theX-Telegram-Bot-Api-Secret-Tokenheader with a case-sensitive lookup against the title-case constant. That works under API Gateway REST API (payload 1.0), which preserves the original client header case, but fails under API Gateway HTTP API (payload 1.0 or 2.0), which lowercases every inbound header name. Users on HTTP API with a configuredsecretTokenhad every update rejected 401, becauseevent.headers["X-Telegram-Bot-Api-Secret-Token"]isundefinedwhen the actual key is"x-telegram-bot-api-secret-token".AWS documents the HTTP API lowercasing in the payload format structure:
REST API users were and are fine; I need them to stay fine.
What changed
const awsLambda: LambdaAdapter = (event, _context, callback) => ({ get update() { return JSON.parse(event.body ?? "{}"); }, - header: event.headers[SECRET_HEADER], + header: event.headers[SECRET_HEADER] ?? + event.headers[SECRET_HEADER_LOWERCASE],Identical change in
awsLambdaAsync. Title-case lookup first (REST API), lowercase fallback second (HTTP API). Both constants already exist at the top of the file and are used by other adapters.No type changes —
LambdaAdapter/LambdaAsyncAdapteralready declareheaders: Record<string, string | undefined>.Coverage matrix
X-Telegram-Bot-Api-Secret-Tokenx-telegram-bot-api-secret-tokenx-telegram-bot-api-secret-tokenTest plan
deno check --allow-import src/mod.ts— cleandeno task test— 38 suites, 443 steps, all passundefinedContext
cc @KnorpelSenf — you green-lit this follow-up in #896. Same reasoning, different adapter pair.