Repository navigation
fix: @W-24143688 add stage.api.salesforce.com to Agent API endpoint fallback - #365
Merged
Merged
Conversation
setu4993
approved these changes
Sep 8, 2026
sf agent preview (and other Agent API calls routed through requestWithEndpointFallback) could not reach agents on orgs served by the stage.api.salesforce.com SFAP gateway (aws-stage1 falcon instance). The fallback only tried api., test.api., and dev.api.salesforce.com, so requests 404'd on every attempt and the CLI threw AgentApiNotFound -- misattributing a routing 404 to a permissions problem. Add 'stage.' to the endpoint fallback list and the host-matching regex. Prod/test/dev behavior is unchanged; stage is only reached as the final fallback after the others 404. Fixes forcedotcom/cli#3645
atulkc
force-pushed
the
aks/add-stage-gateway-fallback
branch
from
September 9, 2026 20:03
4586f6a to
058d3b1
Compare
This was referenced Nov 20, 2026
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.
What
Adds the
stage.SFAP gateway host to the endpoint-fallback list inrequestWithEndpointFallback, sosf agent preview(and other Agent API calls routed through it) can reach agents on orgs served bystage.api.salesforce.com(theaws-stage1falcon instance).Why
requestWithEndpointFallbackonly triedapi.,test.api., anddev.api.salesforce.com. Orgs on theaws-stage1falcon instance are served bystage.api.salesforce.com, which was never attempted — so every request 404s and the CLI throwsAgentApiNotFound("...ensure the user has the necessary permissions..."), which misdiagnoses a routing 404 as an authorization problem. Backend logs confirm the request never reaches the Agent API service; it 404s at the public edge because no attempted host maps to theaws-stage1backend. The same agent previews fine in the Agent Builder UI, which routes internally through that gateway.Fixes forcedotcom/cli#3645.
Fixes gus work item: @W-24143688@
Changes
src/utils.ts: add'stage.'to theendpointsfallback list andstage\.to the host-matching regex; update the doc comment.test/utils.test.ts: add a "retry with stage endpoint after dev endpoint 404" case, and update the "all endpoints fail" assertion to expect 4 attempts.stage.is only reached as the final fallback afterapi./test./dev.return 404, matching the existing pattern — prod/test/dev behavior is unchanged.Testing
yarn tsc -b— clean.yarn mocha test/utils.test.ts— 67 passing (includes the new stage-fallback test).@salesforce/agentsinsf2.150.6 and re-runningsf agent preview -o <aws-stage1 org> -n <Agent>: the request now reachesstage.api.salesforce.comand proceeds past the 404 (previously it failed withAgentApiNotFoundbefore any backend contact).Follow-up (not in this PR)
The
AgentApiNotFoundmessage frames a 404 as a permissions failure. Consider a follow-up to have it report that all Agent API endpoints returned 404 and listattemptedEndpoints, so routing failures aren't misread as auth failures.