Skip to content

Fix staging cloud URL canonicalization#253

Merged
khaliqgant merged 1 commit into
mainfrom
fix/staging-cloud-url
Jun 24, 2026
Merged

Fix staging cloud URL canonicalization#253
khaliqgant merged 1 commit into
mainfrom
fix/staging-cloud-url

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Preserve public stage hosts like staging.agentrelay.cloud instead of rewriting them to production.
  • Add /cloud for bare stage-labeled public hosts so API paths target the Next.js cloud app.
  • Keep origin-bypass canonicalization, mapping origin.agentrelay.cloud to prod and origin-<stage>.agentrelay.cloud to the matching public stage host.
  • Update the weekly-digest staging smoke default to https://staging.agentrelay.cloud/cloud.

Verification

  • pnpm --filter @agentworkforce/deploy test
  • node --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.js
  • pnpm --filter @agentworkforce/cli test currently fails in unrelated local-personas.test.js cascade/sidecar assertions; deploy/login URL tests pass before that failure.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f4303a5-2dd4-4a4a-abc1-a4c90b6621dc

📥 Commits

Reviewing files that changed from the base of the PR and between 5de4da2 and 5720175.

📒 Files selected for processing (3)
  • packages/deploy/src/cloud-url.test.ts
  • packages/deploy/src/cloud-url.ts
  • packages/deploy/test/e2e/weekly-digest.smoke.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/staging-cloud-url

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +47 to +58
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`;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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:';
  }

@khaliqgant khaliqgant merged commit 496fb2a into main Jun 24, 2026
3 checks passed
@khaliqgant khaliqgant deleted the fix/staging-cloud-url branch June 24, 2026 09:22
@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ 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 (preflightPersona accepts authored persona.ts and deploy inputs reach the dev launcher) fail because @agentworkforce/persona-kit and @agentworkforce/runtime workspace packages aren't built/linked in this sandbox (node_modules missing warning confirms it). They are unrelated to cloud-url changes and would fail identically on the base branch.

Review Summary

PR #253 — Fix staging cloud URL canonicalization (packages/deploy/src/cloud-url.ts + tests)

What the PR does

Previously, every *.agentrelay.cloud host was rewritten to production https://agentrelay.com/cloud. This silently redirected explicit staging/preview deploys to production. The PR narrows the rewrite:

  • agentrelay.cloud / origin.agentrelay.cloudhttps://agentrelay.com/cloud (unchanged)
  • origin-<stage>.agentrelay.cloudhttps://<stage>.agentrelay.cloud/cloud (new: strips origin-bypass prefix, preserves stage)
  • bare <stage>.agentrelay.cloud → gets /cloud base path, stage preserved (new)
  • apex agentrelay.com handling unchanged

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

  • tsc compile of the deploy package: clean.
  • cloud-url.test.js: 19/19 pass.
  • Full deploy suite: 207/209 pass. The 2 failures (preflightPersona...persona.ts, deploy inputs reach the dev launcher) are environmental — unbuilt workspace deps (@agentworkforce/persona-kit, @agentworkforce/runtime unresolved; pnpm warns node_modules missing). Unrelated to this diff; they fail on base too.
  • Traced all callers (login.ts, deploy.ts, modes/cloud, integrations-list.ts, CLI commands). The CLI deploy-command.test.ts uses exact origin.agentrelay.cloud → still canonicalizes to production. No caller relied on the old broad *.cloud → prod behavior in a way this breaks.
  • Smoke test DEFAULT_STAGING_URL change (staging.agentrelay.comstaging.agentrelay.cloud/cloud) is a runtime-only default in an un-typechecked JS e2e file (gated behind WORKFORCE_E2E_STAGING_TOKEN); doesn't affect build/CI.

Edits

None. No mechanical/lint issues found; logic is correct and well-tested, so nothing to auto-fix.

Addressed comments

  • No bot or reviewer comments were present in the provided PR metadata (context.json has no review threads; no review-comments file supplied). Nothing to address.

Advisory Notes

  • None.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant