Skip to content

fix(cursor): guard non-array tool_calls in request translator - #12691

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.51from
soroush5:fix-cursor-toolcalls-guard
Sep 6, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.51from
soroush5:fix-cursor-toolcalls-guard

Conversation

@soroush5

@soroush5 soroush5 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

A chat request whose assistant message carries a non-array truthy tool_calls crashed the cursor request translator with a raw TypeError (first is not iterable, then .map is not a function one loop down), surfacing as HTTP 500. Both loops now require an array, matching the sibling kiro translator. The changelog fragment is included per repo convention.

How to test

  1. Call buildCursorRequest with messages: [{ role: "assistant", tool_calls: 5 }] (also tried an object and a string).
  2. Observe no throw now. Before the fix, all three shapes threw TypeError.
  3. Run node --import tsx/esm --test tests/unit/translator-openai-to-cursor.test.ts. All 7 tests pass, including the new #12689 regression test (red without the fix, green with it).

Related issues

Fixes #12689

@diegosouzapw
diegosouzapw merged commit 2b2d34e into cheaper-inference:release/v3.8.51 Sep 6, 2026
3 checks passed
alvinveroy added a commit to alvinveroy/OmniRoute that referenced this pull request Sep 6, 2026
- take upstream useSyncExternalStore combos usage-guide (cheaper-inference#12671) over our
  queueMicrotask lint defuse (supersedes it; suppression already dropped)
- file-size baseline: combos/page.tsx 5066 (upstream shape); keep both
  _rebaseline entries (bounded-abort/tls-ladder + 12671 external store)
- upstream additions folded in: cheaper-inference#12682 sqlite cleanup, cheaper-inference#12691 tool_calls
  guard, cheaper-inference#12834 codex compression re-enable, cheaper-inference#12707 continuation, cheaper-inference#12710
  video-transcript redaction, cheaper-inference#12699 npmrc shipping, docker/deps/docs
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.

Cursor translator crashes with TypeError on non-array tool_calls instead of skipping

2 participants