Skip to content

Fix crash on every request with bandit >= 1.12.1 - #229

Merged
mtrudel merged 1 commit into
mainfrom
fix/handle-connection-delegation
Jul 27, 2026
Merged

Fix crash on every request with bandit >= 1.12.1#229
mtrudel merged 1 commit into
mainfrom
fix/handle-connection-delegation

Conversation

@mtrudel

@mtrudel mtrudel commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dependabot PR Bump bandit from 1.12.0 to 1.12.3 #228 (bumping bandit to 1.12.3) fails all 41 tests across every Elixir/OTP combination in CI, each with ** (KeyError) key :conn_data not found in: %{...} inside Bandit.HTTP1.Handler.handle_data/3.
  • Bandit.HTTP1.Handler gained a handle_connection/2 callback in bandit 1.12.1 (mtrudel/bandit#603) that caches conn_data (peer address lookup) into handler state once per connection, instead of recomputing it on every handle_data/3 call.
  • HAP.HAPSessionHandler wraps Bandit.HTTP1.Handler by delegating handle_data/3 and handle_info/2 straight through to it, but never delegated handle_connection/2 — so it kept Thousand Island's default no-op, state.conn_data was never populated, and every request crashed the connection process.
  • Adds the missing delegation, matching the existing handle_data/3/handle_info/2 pattern.
  • Also bumps bandit (and its transitively-updated deps) in mix.lock to 1.12.3 so CI actually exercises the version this fixes against, rather than the still-locked 1.12.0.

Test plan

  • mix test passes locally against bandit 1.12.3 (41 tests, 0 failures)
  • mix credo clean on the changed file

🤖 Generated with Claude Code

Bandit 1.12.1 (mtrudel/bandit#603) moved conn_data (peer address
lookup) out of handle_data/3 and into a new handle_connection/2
callback that caches it once per connection in handler state, instead
of recomputing it on every request. HAP.HAPSessionHandler wraps
Bandit.HTTP1.Handler by delegating handle_data/3 and handle_info/2 to
it directly, but never delegated handle_connection/2, so it kept
Thousand Island's default no-op instead - state.conn_data was never
populated, and every request crashed the connection process with
`** (KeyError) key :conn_data not found`.

Add the missing delegation, matching the existing handle_data/3 and
handle_info/2 pattern. Also bumps bandit (and its own updated
dependencies) in mix.lock to 1.12.3 so CI actually exercises the
version this fixes against, rather than the still-locked 1.12.0.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mtrudel
mtrudel merged commit e667f54 into main Jul 27, 2026
15 of 30 checks passed
@mtrudel
mtrudel deleted the fix/handle-connection-delegation branch July 27, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant