Skip to content

Requests to rec without a Content-Length fail with 400 on an int(None) attempt #34

Open

Description

@wrossmorrow

What happened

Requests to rec-served flint fail for streamed requests without a Content-Length, as (for example) envoy might do when streaming bodies through external processing which converts to Transfer-Encoding: chunked. Such a request fails without an intermediary though and is directly reproducible. In other words, middleware between clients and rec may break rec's ability to handle the request.

Steps to reproduce

With a running rec server instance,

% rec status
  ● flint is running  http://127.0.0.1:11500/v1
    Context 262,144 tokens · rec 0.1.0

query as

% curl -s http://127.0.0.1:11500/v1/chat/completions \
  -H "Authorization: Bearer $( rec auth token )" \
  -H 'Content-Type: application/json' \
  -H 'Transfer-Encoding: chunked' \
  -d '{"model":"flint","messages":[{"role":"user","content":"hi"}],"max_tokens":8}'
{"error": "int() argument must be a string, a bytes-like object or a real number, not 'NoneType'"}

This likely comes from do_POST in the Handler casting int() on a header value that can be missing/None.

Output

As above

{"error": "int() argument must be a string, a bytes-like object or a real number, not 'NoneType'"}

for any request without a Content-Length, like a streamed request.

Environment

Mac Tahoe 26.5.1, 48GB

% sysctl -n machdep.cpu.brand_string hw.memsize
Apple M5 Max
51539607552
% rec --version
rec 0.1.0
  • I removed API keys, tokens, and private content from this report.

Activity

  1. changed the title [-]Requests to rec with a Content-Length fail with 400 on an int(None) attempt[/-] [+]Requests to rec without a Content-Length fail with 400 on an int(None) attempt[/+] on Oct 26, 2026
  2. strin commented on Nov 5, 2026

    @strin

    Thanks for the clear reproduction. I reproduced the missing Content-Length failure and opened #51 to accept bounded chunked bodies on both OpenAI and Anthropic routes, including streaming responses. The focused suite passed 44 tests and covers malformed/ambiguous framing and admission cleanup. It is still a proposed fix, not part of a release yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions