Skip to content

Fix model fallback crash on undefined provider/model (#946)#954

Merged
steipete merged 2 commits intoopenclaw:mainfrom
roshanasingh4:fix/946-openai-completions-trim
Jan 15, 2026
Merged

Fix model fallback crash on undefined provider/model (#946)#954
steipete merged 2 commits intoopenclaw:mainfrom
roshanasingh4:fix/946-openai-completions-trim

Conversation

@roshanasingh4
Copy link
Copy Markdown
Contributor

Fixes #946.

Problem

When using a custom local provider with api: "openai-completions" (or openai-responses), the gateway could crash before any HTTP request with:

Cannot read properties of undefined (reading 'trim')

This happens because the model fallback code called .trim() on provider/model without guarding against undefined values during preflight model selection.

Fix

Coerce provider and model to strings and fall back to defaults when missing, instead of calling .trim() directly.

Tests

Adds a regression test that passes undefined provider/model to runWithModelFallback and asserts it safely defaults.

@steipete steipete self-assigned this Jan 15, 2026
@steipete steipete force-pushed the fix/946-openai-completions-trim branch from dc9cde6 to c043e97 Compare January 15, 2026 16:59
@steipete steipete merged commit fc4aa9a into openclaw:main Jan 15, 2026
21 of 22 checks passed
@steipete
Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: c043e97\n- Merge commit: fc4aa9a\n\nThanks @roshanasingh4!

michaelhaessig pushed a commit to michaelhaessig/clawdbot that referenced this pull request Jan 15, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…pletions-trim

Fix model fallback crash on undefined provider/model (openclaw#946)
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.

openai-completions API fails with custom local providers: Cannot read properties of undefined (reading 'trim')

2 participants