#6112: refactor: add early return for invalid Authorization headers
gateway
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR tweaks `getBearerToken` in `src/gateway/http-utils.ts` to return early when the `Authorization` header is missing/empty (after trimming) rather than defaulting to an empty string, while keeping the existing `Bearer …` prefix parsing.
The change sits in the gateway request parsing helpers used to normalize headers and resolve auth/session routing inputs.
<h3>Confidence Score: 4/5</h3>
- This PR is low risk and narrowly scoped to bearer-token parsing.
- The change is small and localized, with no obvious behavioral regressions for valid headers; main concern is a minor readability/perceived intent issue around the added length check.
- src/gateway/http-utils.ts
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#8779: fix(security): use constant-time comparison for token validation
by hleliofficiel · 2026-02-04
74.8%
#6110: refactor: simplify boolean logic using nullish coalescing
by T1mn · 2026-02-01
74.6%
#15722: fix: prefer explicit token over stored device token for remote gate...
by 0xPotatoofdoom · 2026-02-13
74.0%
#6352: fix(ux): update gateway token error message UI location
by Glucksberg · 2026-02-01
73.7%
#14197: fix(security): harden browser API auth, token comparisons, and hook...
by leecarollyn-gif · 2026-02-11
72.8%
#19937: fix(gateway): validate token/password auth modes and isolate gatewa...
by NewdlDewdl · 2026-02-18
72.6%
#23139: test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present
by Imccccc · 2026-02-22
72.5%
#9440: fix(security): warn users when gateway token appears in URLs
by zenchantlive · 2026-02-05
72.2%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
72.1%
#10745: feat: Security improvements and Windows compatibility fixes
by lluviaoscuradeldoce-design · 2026-02-06
72.0%