You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cli): canonicalize cloud URL and rewrite agent-relay error hints (#117)
The customer hit two stacked CLI bugs in one deploy:
- ensureAuthenticated occasionally returns auth.apiUrl pointing at the
SST edge-bypass hostname (origin.agentrelay.cloud). Persisting that
into active.json sends every subsequent API call cross-subdomain,
where session cookies and Bearer tokens don't validate, so every
call 401s.
- The 401 hint then told `agentworkforce` users to run `agent-relay
cloud whoami` / `agent-relay cloud login`, which they don't have.
Add canonicalizeCloudUrl() and apply it at every CLI write/consume
site for the cloud URL (login --cloud-url, ensureAuthenticated result,
writeActiveWorkspace, resolveWorkspaceToken). Known-bypass hostnames
(origin.*, *.agentrelay.cloud) remap to https://agentrelay.com/cloud;
localhost and unrelated tenants pass through untouched.
Rewrite the 401 / 403 error strings in relayfileIntegrationResolver
so they point at `agentworkforce login` instead of `agent-relay cloud
whoami`, and drop the hardcoded origin.agentrelay.cloud URL from the
hint text. Same sweep across help / usage strings.
Tests cover the canonicalization table, the login-time canonicalization
end-to-end (origin.* apiUrl -> public canonical written), and a
relayfileIntegrationResolver 401 surfacing the new agentworkforce-native
hint (regex match so future copy-edits don't break it).
Co-authored-by: Ricky Schema Cascade <ricky@agent-relay.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/deploy/src/connect.test.ts
+30-9Lines changed: 30 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ test('connectIntegrations fails fast on auth errors without prompting to connect
124
124
integrations: {
125
125
asyncisConnected(){
126
126
thrownewError(
127
-
'cloud integration request failed: unauthorized. Open https://origin.agentrelay.cloud/cloud to verify your cloud session, then run `agent-relay cloud whoami` and `agentworkforce login` to refresh the active workspace.'
127
+
'cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.'
128
128
);
129
129
},
130
130
asyncconnect(){
@@ -136,18 +136,39 @@ test('connectIntegrations fails fast on auth errors without prompting to connect
136
136
137
137
assert.equal(confirmCalled,false);
138
138
assert.equal(connectCalled,false);
139
-
assert.deepEqual(result.outcomes,[
140
-
{
141
-
provider: 'notion',
142
-
status: 'failed',
143
-
message:
144
-
'cloud integration request failed: unauthorized. Open https://origin.agentrelay.cloud/cloud to verify your cloud session, then run `agent-relay cloud whoami` and `agentworkforce login` to refresh the active workspace.'
145
-
}
146
-
]);
139
+
assert.equal(result.outcomes.length,1);
140
+
const[outcome]=result.outcomes;
141
+
assert.equal(outcome.provider,'notion');
142
+
assert.equal(outcome.status,'failed');
143
+
// Future-proofed against copy-edits: the message must point users at the
144
+
// workforce CLI's own login and must NOT instruct them to reach for the
Copy file name to clipboardExpand all lines: packages/deploy/src/connect.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -318,12 +318,12 @@ async function requestJson(
318
318
});
319
319
if(res.status===401){
320
320
thrownewError(
321
-
'cloud integration request failed: unauthorized. Open https://origin.agentrelay.cloud/cloud to verify your cloud session, then run `agent-relay cloud whoami` and `agentworkforce login` to refresh the active workspace.'
321
+
'cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.'
322
322
);
323
323
}
324
324
if(res.status===403){
325
325
thrownewError(
326
-
'cloud integration request failed: forbidden. The active account is not authorized for this workspace; open https://origin.agentrelay.cloud/cloud to verify account/workspace access, then run `agent-relay cloud whoami` and `agentworkforce login` to refresh the active workspace.'
326
+
'cloud integration request failed: forbidden. The active account is not authorized for this workspace. Run `agentworkforce login --workspace <id-or-slug>` against an account with access, then retry.'
0 commit comments