Fix crash on every request with bandit >= 1.12.1 - #229
Merged
Conversation
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>
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
banditto 1.12.3) fails all 41 tests across every Elixir/OTP combination in CI, each with** (KeyError) key :conn_data not found in: %{...}insideBandit.HTTP1.Handler.handle_data/3.Bandit.HTTP1.Handlergained ahandle_connection/2callback in bandit 1.12.1 (mtrudel/bandit#603) that cachesconn_data(peer address lookup) into handler state once per connection, instead of recomputing it on everyhandle_data/3call.HAP.HAPSessionHandlerwrapsBandit.HTTP1.Handlerby delegatinghandle_data/3andhandle_info/2straight through to it, but never delegatedhandle_connection/2— so it kept Thousand Island's default no-op,state.conn_datawas never populated, and every request crashed the connection process.handle_data/3/handle_info/2pattern.bandit(and its transitively-updated deps) inmix.lockto 1.12.3 so CI actually exercises the version this fixes against, rather than the still-locked 1.12.0.Test plan
mix testpasses locally against bandit 1.12.3 (41 tests, 0 failures)mix credoclean on the changed file🤖 Generated with Claude Code