Skip to content

fix(chat): skip null entries in tools and input in the session fingerprint and the Claude tool conversion - #17023

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.52from
pacocartones:fix/null-tools-input-entries
Oct 18, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.52from
pacocartones:fix/null-tools-input-entries

Conversation

@pacocartones

Copy link
Copy Markdown
Contributor

Summary

  • A null entry in tools (or in input/messages when the session fingerprint is computed) made generateSessionId and the OpenAI→Claude tool conversion throw a TypeError instead of ignoring the entry. Such entries are now skipped, as an entry without a name already is. A request without null entries behaves as before.
  • Root cause: tools and input are z.array(z.unknown()) in the request schema, so a null entry reaches these readers. generateSessionId read t.name on every tools entry and msg.role on every messages/input entry, and openaiToClaudeRequest read tool.function, all without a guard. messages: [null] already answers 400 since fix(chat): reject null/non-object entries in messages[] (#12643) #13755.

Related Issues

  • None found: no open or closed pull request or issue covers this (checked today by the touched paths and function names).

Target Branch

  • Base is the active release/v3.8.x branch (the highest open release/v*, here release/v3.8.52), not main

Proof Of Fix (required)

  • TDD — a test that fails before the fix and passes after it.
    • Test file: tests/unit/null-entries-in-tools-and-input.test.ts (new, 3 cases: a null entry in tools and in input/messages for the session fingerprint, and a null entry in tools for the OpenAI→Claude conversion, which keeps the valid tool).
    • Failing output before the fix (base release/v3.8.52 with only sessionManager.ts and openai-to-claude.ts reverted):
      ✖ generateSessionId ignores a null entry in tools
        TypeError: Cannot read properties of null (reading 'name')
      ✖ generateSessionId ignores a null entry in input and in messages
        TypeError: Cannot read properties of null (reading 'role')
      ✖ OpenAI to Claude drops a null entry in tools and keeps the valid tool
        TypeError: Cannot read properties of null (reading 'function')
      ℹ tests 3
      ℹ pass 0
      ℹ fail 3
      
    • With the fix: 3 of 3 pass.
  • Real-environment test: not done; I did not run a request through the server, so I did not measure which HTTP status the TypeError becomes there.

Scope

  • Only the files the failing test proves need changing are touched: open-sse/services/sessionManager.ts, open-sse/translator/request/openai-to-claude.ts, the new test and a one-line changelog fragment.
  • No test was weakened or deleted.

Validation

  • Change type: request handling (session fingerprint and OpenAI→Claude translation)
  • Focused tests: every tests/unit/openai-to-claude* and session* test file, run together with the new file: 739 of 739 pass.
  • prettier --check on the new test and the changelog fragment, check:ai-attribution --range and check:changelog-integrity pass. eslint on openai-to-claude.ts reports one unused toolNameMap; it is on the base and this change does not touch it.

Reviewer Notes

  • Changelog fragment: changelog.d/fixes/PENDING-null-entries-in-tools-and-input.md, one line, left for you to rename.

…print and the Claude tool conversion

tools and input are z.array(z.unknown()) in the request schema. generateSessionId read t.name on every tools entry and msg.role on every messages/input entry, and the OpenAI to Claude conversion read tool.function, so a null entry threw a TypeError (messages: [null] has answered 400 since cheaper-inference#13755). Guard the three readers in sessionManager.ts and the tool map in openai-to-claude.ts; a null entry is ignored, as an entry without a name already is.
@diegosouzapw
diegosouzapw merged commit 4c1472d into cheaper-inference:release/v3.8.52 Oct 18, 2026
42 of 60 checks passed
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.

2 participants