Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@roshanasingh4
Copy link
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
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
cpojer pushed a commit to cpojer/clawdbot that referenced this pull request Jan 16, 2026
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