fix: actually check the endpoint during setup
async_setup_entry handed client.with_options(timeout=10.0).models.list to the executor. On AsyncOpenAI that returns an awaitable paginator, so it came back unawaited, no request was made, and a bad key or an unreachable endpoint still set up. It now awaits client.models.list(timeout=10.0), matching core's openai_conversation, so a 401 raises ConfigEntryAuthFailed and a connection error ConfigEntryNotReady, as the README already says. The shared mock_init_component fixture now patches models.list with an AsyncMock and keeps the patch for the whole test, because tests that change a subentry reload the entry and run setup again. Reported by @MartinNuc in #1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SUd68TsT5QZ68Dtfw2uWBU
This commit is contained in:
1 parent
151d741a71
commit
a6faa44b2f
3 files changed
+64
-7
No files matched your search
@@ -294,7 +294,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenAIConfigEntry) -> bo
|
||||
_ = await hass.async_add_executor_job(client.platform_headers)
|
||||
|
||||
try:
|
||||
await hass.async_add_executor_job(client.with_options(timeout=10.0).models.list)
|
||||
await client.models.list(timeout=10.0)
|
||||
except openai.AuthenticationError as err:
|
||||
raise ConfigEntryAuthFailed(err) from err
|
||||
except openai.OpenAIError as err:
|
||||
|
||||
Reference in new issue
Block a user