Skip to content

interface_http.py fails in assert_equal(response2.status, http.client.BAD_REQUEST) AssertionError: not(413 == 400) #35082

Closed

Description

@maflcko

no idea how to reproduce this, but it seems to fail in https://github.com/maflcko/bitcoin-core-nightly/actions/runs/24438190980/job/71397012801#step:11:1626:

 test  2026-04-15T06:46:03.124196Z TestFramework (INFO): Check excessive size HTTP request encoded with chunked transfer 
 test  2026-04-15T06:46:03.198837Z TestFramework (ERROR): Unexpected exception: 
                                   Traceback (most recent call last):
                                     File "/__w/bitcoin-core-nightly/bitcoin-core-nightly/test/functional/test_framework/test_framework.py", line 143, in main
                                       self.run_test()
                                     File "/__w/bitcoin-core-nightly/bitcoin-core-nightly/bld/test/functional/interface_http.py", line 109, in run_test
                                       self.check_chunked_transfer()
                                     File "/__w/bitcoin-core-nightly/bitcoin-core-nightly/bld/test/functional/interface_http.py", line 312, in check_chunked_transfer
                                       assert_equal(response2.status, http.client.BAD_REQUEST)
                                     File "/__w/bitcoin-core-nightly/bitcoin-core-nightly/test/functional/test_framework/util.py", line 83, in assert_equal
                                       raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
                                   AssertionError: not(413 == 400)

I tried this in a fresh ubuntu:noble container locally, but it passed:

# history 
    1  export DEBIAN_FRONTEND=noninteractive && apt update && apt install curl wget htop git vim ccache -y && git clone https://github.com/bitcoin/bitcoin.git  --depth=1 ./b-c && cd b-c && apt install  build-essential cmake pkg-config  python3-zmq libzmq3-dev libevent-dev libboost-dev libsqlite3-dev  systemtap-sdt-dev  libcapnp-dev capnproto  libqrencode-dev qt6-tools-dev qt6-l10n-tools qt6-base-dev  clang llvm libc++-dev libc++abi-dev  mold -y 
    2  wget https://apt.llvm.org/llvm.sh 
    3  bash ./llvm.sh 23
 
    6  cmake -B bld-23     -DAPPEND_CXXFLAGS='-O3 -g2'       -DAPPEND_CFLAGS='-O3 -g2'       -DCMAKE_BUILD_TYPE=Debug -DAPPEND_CPPFLAGS='-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES' -DCMAKE_C_COMPILER="clang-23" -DCMAKE_CXX_COMPILER="clang++-23;-stdlib=libstdc++"     --preset=dev-mode     -DCMAKE_COMPILE_WARNING_AS_ERROR=ON && cmake --build ./bld-23 --parallel  $(nproc) --target=bitcoind && ./bld-23/test/functional/interface_http.py
 

Originally posted by @maflcko in #34772

Activity

  1. pinheadmz commented on Apr 15, 2026

    @pinheadmz
    Member

    looking in to this today. 413 is content too large which makes sense, maybe a race in libevent between that and generic 400 bad request

  2. pinheadmz commented on Apr 15, 2026

    @pinheadmz
    Member

    OMG Claude is fucking amazing:

    https://github.com/libevent/libevent/blob/48296514d8fd9c0b3812b11d45ad80b0c002c14e/http.c#L1025-L1027

    1. Line 1022: buflen > EV_SSIZE_MAX fires before the chunk size is even parsed — if client sends chunk header + large data together, this fires. If they arrive in separate TCP segments, the max_body_size check at line 1065 fires instead. This is the race condition causing "sometimes 413, more often 400".
  3. added this to the 32.0 milestone on Apr 15, 2026
  4. pinheadmz commented on Apr 15, 2026

    @pinheadmz
    Member

    Ok I got too excited, the problem is not as cool as claude thinks. There is still a race condition already described by a comment in the test, I just never correctly observed one path of the race. 413 is the expected error code and I can reproduce it, will update this test with a follow-up PR.

  5. added a commit that references this issue on Apr 17, 2026
    654556e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions