Skip to content

fix(py): stop OpenAI generate from raising when config is omitted - #6234

Closed
hilariie wants to merge 1 commit into
mainfrom
fix/py-openai-normalize-config-none
Closed

hilariie wants to merge 1 commit into
mainfrom
fix/py-openai-normalize-config-none

Conversation

@hilariie

@hilariie hilariie commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Why

ModelRequest.config defaults to None and normalize_config had no None branch, so it fell through to the final raise. OpenAIModel.generate and OpenAIModelHandler.generate both call it unconditionally, so any generate request that omitted config raised ValueError before reaching the API.

Changes

normalize_config returns a default OpenAIConfig() when config is None, and the annotation widens to object | None. This matches the JS plugin and the Anthropic plugin, and the request body is unchanged: OpenAIConfig() has no non-None defaults and _openai_create_kwargs drops None values, so nothing extra reaches the API.

The test_normalize_config case asserting that None raises now expects OpenAIConfig(); an int case keeps the ValueError branch covered.

Verification

A no-config request through both generate paths now completes with a {messages, model} body, the same body built when config is present but empty. Previously both raised.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the normalize_config method in the Genkit OpenAI model implementation to support None as a valid configuration input, returning a default OpenAIConfig instance when it is provided. It also updates the corresponding unit tests to verify this behavior and adds a test case for invalid configuration types. There are no review comments, so I have no feedback to provide.

@MichaelDoyle

Copy link
Copy Markdown
Contributor

Closing as superseded: Python SDK development has moved to https://github.com/genkit-ai/genkit-python, and omitted config hydration is now handled centrally by the unified Python config pipeline (#6712).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants