Fix staging cloud URL canonicalization#253
Conversation
|
Warning Review limit reached
More reviews will be available in 59 minutes and 23 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the canonicalizeCloudUrl utility to properly handle staging and preview URLs (such as preserving staging.agentrelay.cloud and mapping origin-<stage> bypass hostnames back to their public counterparts) instead of mapping all subdomains to the production apex. It also updates corresponding tests and E2E test constants. Feedback suggests mutating the URL object directly rather than returning hardcoded string literals to ensure other URL components like query parameters, ports, and subpaths are preserved.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (host === 'agentrelay.cloud' || host === 'origin.agentrelay.cloud') { | ||
| return 'https://agentrelay.com/cloud'; | ||
| } | ||
| if (host.startsWith('origin-') && host.endsWith('.agentrelay.cloud')) { | ||
| return `https://${host.slice('origin-'.length)}/cloud`; | ||
| } | ||
| if ( | ||
| host.endsWith('.agentrelay.cloud') && | ||
| (url.pathname === '' || url.pathname === '/') | ||
| ) { | ||
| return `https://${host}/cloud`; | ||
| } |
There was a problem hiding this comment.
Instead of returning hardcoded string literals and discarding other parts of the URL (such as ports, query parameters, hashes, or non-root subpaths), we can mutate the URL object directly. This is much more robust, preserves any additional URL metadata, and avoids manual string concatenation.
For example, if a URL like https://origin-preview-pr-113.agentrelay.cloud/cloud/some-path?debug=true is passed, mutating the URL object will correctly preserve the subpath and query parameters, whereas the current implementation would completely discard them.
if (host === 'agentrelay.cloud' || host === 'origin.agentrelay.cloud') {
url.hostname = 'agentrelay.com';
url.protocol = 'https:';
if (url.pathname === '' || url.pathname === '/') {
url.pathname = '/cloud';
}
} else if (host.startsWith('origin-') && host.endsWith('.agentrelay.cloud')) {
url.hostname = host.slice('origin-'.length);
url.protocol = 'https:';
if (url.pathname === '' || url.pathname === '/') {
url.pathname = '/cloud';
}
} else if (
host.endsWith('.agentrelay.cloud') &&
(url.pathname === '' || url.pathname === '/')
) {
url.pathname = '/cloud';
url.protocol = 'https:';
}|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. Working tree is clean — I made no edits (none were warranted). The 2 failing tests ( Review SummaryPR #253 — Fix staging cloud URL canonicalization ( What the PR doesPreviously, every
This is a safety improvement (fail-closed): it prevents staging traffic from leaking to production. Branch ordering is correct, no fail-open regressions introduced. Verification
EditsNone. No mechanical/lint issues found; logic is correct and well-tested, so nothing to auto-fix. Addressed comments
Advisory Notes
The PR is correct, scoped, and its own tests pass. The only failing checks I observed are sandbox-environmental (missing built workspace deps), not PR-caused — but I cannot confirm CI status, and required checks may still be pending/running on the actual PR. I am therefore not declaring it ready. |
Summary
staging.agentrelay.cloudinstead of rewriting them to production./cloudfor bare stage-labeled public hosts so API paths target the Next.js cloud app.origin.agentrelay.cloudto prod andorigin-<stage>.agentrelay.cloudto the matching public stage host.https://staging.agentrelay.cloud/cloud.Verification
pnpm --filter @agentworkforce/deploy testnode --test packages/cli/dist/deploy-command.test.js packages/cli/dist/integrations-command.test.js packages/cli/dist/list-command.test.js packages/cli/dist/destroy-command.test.js packages/cli/dist/trigger-command.test.jspnpm --filter @agentworkforce/cli testcurrently fails in unrelatedlocal-personas.test.jscascade/sidecar assertions; deploy/login URL tests pass before that failure.