fix: show clear error when Cloudflare provider env vars are missing#20399
Open
mchenco wants to merge 2 commits intoanomalyco:devfrom
Open
fix: show clear error when Cloudflare provider env vars are missing#20399mchenco wants to merge 2 commits intoanomalyco:devfrom
mchenco wants to merge 2 commits intoanomalyco:devfrom
Conversation
82b7d5e to
ea21b48
Compare
elithrar
reviewed
Apr 1, 2026
Contributor
elithrar
left a comment
There was a problem hiding this comment.
LGTM from our/the Cloudflare side. Makes the missing env vars more explicit.
bf6a847 to
ea21b48
Compare
ea21b48 to
4aa1bd6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Fixes #20398
Type of change
What does this PR do?
When users connect
cloudflare-workers-aiorcloudflare-ai-gatewayvia/connect, the API key is saved in auth. But the custom loaders also needCLOUDFLARE_ACCOUNT_ID(andCLOUDFLARE_GATEWAY_IDfor gateway) as env vars.When those env vars are missing, the loaders return
{ autoload: false }without agetModel. Since the provider is already in the providers map from auth, the loader result is still processed (result.autoload || providers[providerID]), but no model loader gets registered. When the user sends a message, the fallback callssdk.languageModel(model.api.id)which crashes withsdk.languageModel is not a function.The fix adds a
getModelto the early returns that throws a clear error naming the missing env var with the export command, e.g.:How did you verify your code works?
/connectauth withoutCLOUDFLARE_ACCOUNT_ID, confirms the provider loads from auth, and verifiesgetLanguagethrows the clear error instead of crashingScreenshots / recordings
Not a UI change.
Checklist