[Bug]: UI "Connect" button silently fails to prompt for API keys and falsely reports "Ready to use" when provider bootstrap fails
Summary
When the OpenCode engine encounters a configuration error (such as a missing npm or baseURL field for a custom provider), it throws a fetch() URL is invalid error during the provider authentication handshake. Because the OpenWork UI relies on this endpoint to initiate the login flow, clicking the "Connect" button silently fails. The UI does not display an error, does not prompt the user for an API key, and incorrectly displays a green "Ready to use" status because the provider is defined in openwork.json, leaving the user trapped in an unauthenticated state.
To Reproduce
- Ensure
auth.jsondoes not contain the API key for the listed provider. - Ensure
openwork.jsondefines the provider but lacks the requirednpmorbaseURLfields (or has a malformed schema that prevents the engine's provider metadata from loading). - Launch OpenWork and go to Settings -> AI Providers.
- Observe that the provider has a green dot and says "Ready to use".
- Click Disconnect, then Connect.
- Observe that no dialog appears asking for an API key. The UI immediately reverts to showing "Ready to use".
- Go to a chat and try to send a message. It fails with "Check your model connection".
- Run
opencode auth login <provider>in the terminal. It fails withError: Failed to load auth provider metadata from <provider>: fetch() URL is invalid.
Expected behavior
- The "Connect" button should trigger a dialog to input the API key.
- If the backend endpoint fails to fetch provider metadata, the UI should display a red error state and explicitly state "Failed to load provider metadata," rather than silently swallowing the error and showing "Ready to use."
- The UI should verify that a key actually exists in
auth.json(or the environment) before displaying a green "Ready to use" status.
Actual behavior
- The engine crashes during provider metadata bootstrap (
fetch() URL is invalid). - The OpenWork server swallows the engine error.
- The UI interprets the provider's presence in
openwork.jsonas "Authenticated", shows a green dot, and blocks the key-entry prompt. - The user is trapped in a ghost state where the UI says they are connected, but the engine has no keys and refuses to send messages.
Screenshots (optional)
No response
OW version & Desktop info (optional)
- OS: Windows 11 (pt-BR)
- OpenWork Version: 0.18.58
- OpenCode Version: 1.18.30
Additional context (optional)
Suggested Fixes:
- Handle Metadata Bootstrap Failures: If the
/providerendpoint fails to return valid metadata, the UI should display a specific error to the user (e.g., "Configuration error: Unable to load provider metadata"), rather than assuming the provider is authenticated. - Validate Auth State: The green "Ready to use" dot should be tied to the existence of the key in
auth.jsonor the system environment, not just the presence of the provider string inopenwork.json. - Force Prompt: If a user clicks "Connect" and no key is found, the UI should force the API key prompt regardless of the config state.
(This was filed with AI assistance.)
Hi, I'd like to take this one. I have a fix ready that opens the Connect dialog with the engine's error instead of failing silently, PR coming in a few minutes.
Fixed in #6909, released in v0.18.65. When OpenWork can't load a provider's sign-in methods (for example a custom provider without npm or baseURL), Connect now opens its dialog with the engine's error instead of doing nothing. If a provider still shows "Ready to use" without a key, please comment here.