Skip to content

TRT-2756: Test-details links in on-demand staging environment point to localhost#3704

Merged
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
openshift-trt:trt-2756
Jun 26, 2026
Merged

TRT-2756: Test-details links in on-demand staging environment point to localhost#3704
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
openshift-trt:trt-2756

Conversation

@openshift-trt-agent

@openshift-trt-agent openshift-trt-agent Bot commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Fixes test-details "latest" links pointing to localhost in staging and production environments.

The jsonComponentReportTestDetailsFromBigQuery handler was using api.GetBaseURL(req) to construct the base URL for generated links. GetBaseURL derives the host from req.Host, which resolves to localhost in proxied environments (like on-demand staging). The sibling handler jsonComponentReportFromBigQuery already uses api.GetBaseFrontendURL(req), which prefers the Origin header (containing the actual frontend host) and falls back to GetBaseURL when no origin is present. This fix applies the same pattern to the test-details handler.

Fixes: TRT-2756

Test plan

  • go vet passes on affected packages
  • make lint passes (0 issues)
  • Unit tests pass for pkg/sippyserver and pkg/api/...
  • E2e tests pass (107/108; sole failure is pre-existing BigQuery access issue in TestRegressionCacheLoader)
  • Verified that GetBaseFrontendURL is already used correctly in the component report handler (line 1027) and that the link injector middleware receives the correct base URL through that flow

Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Updated component test-details links to open in the correct frontend location.
    • Improved handling of server-provided test-details URLs so they’re converted and used directly when available.
    • Simplified API-to-UI URL mapping to reduce incorrect or mismatched link destinations.
  • Tests
    • Added/expanded unit coverage for API-to-UI URL conversion and test-details link generation (including fallback behavior).

Use GetBaseFrontendURL instead of GetBaseURL in the test details handler
so the generated "latest" links use the Origin header (the frontend's
host) rather than the backend's request Host, which resolves to
localhost in proxied environments like on-demand staging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 26, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 26, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 26, 2026

Copy link
Copy Markdown

@openshift-trt-agent[bot]: This pull request references TRT-2756 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Fixes test-details "latest" links pointing to localhost in staging and production environments.

The jsonComponentReportTestDetailsFromBigQuery handler was using api.GetBaseURL(req) to construct the base URL for generated links. GetBaseURL derives the host from req.Host, which resolves to localhost in proxied environments (like on-demand staging). The sibling handler jsonComponentReportFromBigQuery already uses api.GetBaseFrontendURL(req), which prefers the Origin header (containing the actual frontend host) and falls back to GetBaseURL when no origin is present. This fix applies the same pattern to the test-details handler.

Fixes: TRT-2756

Test plan

  • go vet passes on affected packages
  • make lint passes (0 issues)
  • Unit tests pass for pkg/sippyserver and pkg/api/...
  • E2e tests pass (107/108; sole failure is pre-existing BigQuery access issue in TestRegressionCacheLoader)
  • Verified that GetBaseFrontendURL is already used correctly in the component report handler (line 1027) and that the link injector middleware receives the correct base URL through that flow

Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from sosiouxme and xueqzhan June 26, 2026 11:39
@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 26, 2026
@openshift-ci

openshift-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Hi @openshift-trt-agent[bot]. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

/test staging

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

/test agentic-staging

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 26, 2026
@openshift-trt-agent

Copy link
Copy Markdown
Author

Sippy Staging Environment

URL: https://weather-emerald-organizer-violation.trycloudflare.com

This environment is built from this PR and will remain available for approximately 60 minutes (until ~13:13 UTC).

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

This doesn't work, and the staging environment confirms it. Attempting to navigate to a test_details report from the RegressedTestModal is non-functional.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

/hold Claude was working on fixing my comment, but there is a 15 minute timeout for followups, and it was killed in the middle. I need to increase that

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 26, 2026
convertApiUrlToUiUrl was preserving the full URL including scheme+host
from HATEOAS links. In staging (same-origin), browsers omit the Origin
header on GET requests so GetBaseFrontendURL falls back to req.Host
(e.g. localhost:8080), producing unreachable links. Strip the origin
and emit relative paths (/sippy-ng/...) so the browser resolves them
against whatever host the user is actually on.

Also removes debug console.log statements and the compareUrlQueryParams
helper that was only used for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-trt-agent

Copy link
Copy Markdown
Author

@smg247 Fixed. The root cause was in the frontend's convertApiUrlToUiUrl function in CompReadyUtils.js.

The problem: When the backend generates HATEOAS test_details links, it uses GetBaseFrontendURL(req) which prefers the Origin header. In staging (same-origin), browsers don't send the Origin header on same-origin GET requests, so it falls back to req.Host (e.g. localhost:8080). The old convertApiUrlToUiUrl preserved that full URL including scheme+host, producing links like http://localhost:8080/sippy-ng/... which are unreachable from the user's browser.

The fix: convertApiUrlToUiUrl now strips the scheme+host and produces relative paths (e.g. /sippy-ng/component_readiness/test_details?...). The browser resolves these relative paths against whatever host the user is actually on, so it works correctly in both dev (localhost:3000) and staging/production environments.

Also cleaned up debug console.log statements and the compareUrlQueryParams helper that was only used for debugging.

All e2e tests pass (107/108, the one failure is TestRegressionCacheLoader due to missing BigQuery credentials in the dev environment).

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

/test agentic-staging

@openshift-trt-agent

Copy link
Copy Markdown
Author

Sippy Staging Environment

URL: https://few-useful-tales-turtle.trycloudflare.com

This environment is built from this PR and will remain available for approximately 60 minutes (until ~19:52 UTC).

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

This works nicely on staging now. Since the change is larger in scope, I will check this out locally and confirm.

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Confirmed this works locally. No real way to test prod without merging, but it should be safe.

/lgtm

@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9ef03d5a-0c10-4640-99a9-5d38836d68ed

📥 Commits

Reviewing files that changed from the base of the PR and between acf64ec and 0867d36.

📒 Files selected for processing (1)
  • sippy-ng/src/component_readiness/CompReadyUtils.test.js

Walkthrough

The server now uses the frontend base URL when building component readiness test-details links, and the frontend converts server-provided API links into UI links before returning them.

Changes

Component readiness test-details links

Layer / File(s) Summary
Frontend base URL source
pkg/sippyserver/server.go
jsonComponentReportTestDetailsFromBigQuery now passes api.GetBaseFrontendURL(req) into test-details link generation instead of api.GetBaseURL(req).
URL rewrite and link return
sippy-ng/src/component_readiness/CompReadyUtils.js
convertApiUrlToUiUrl now rewrites links from the first /api/ segment, and generateTestDetailsReportLink returns the converted server test-details link directly when one is present.
Frontend tests
sippy-ng/src/component_readiness/CompReadyUtils.test.js
Tests cover the rewritten API-to-UI URL behavior and the test-details link fallback path when a server link is absent.

Estimated review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 21
✅ Passed checks (21 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing test-details links that pointed to localhost in staging.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Go Error Handling ✅ Passed The Go diff only swaps GetBaseURL for GetBaseFrontendURL; no new error handling, panic, or nil-deref issues were introduced.
Sql Injection Prevention ✅ Passed The PR only changes URL/baseURL handling and tests; no SQL query construction, concatenation, or DB access logic was added in the touched code.
Excessive Css In React Should Use Styles ✅ Passed PR only changes URL utility/test code and a Go handler; it adds no React component styling or new large inline style objects.
Test Coverage For New Features ✅ Passed PASS: Added regression tests cover the new URL rewrite and test-details link fallback behavior in CompReadyUtils.js; the Go change is a call-site swap.
Single Responsibility And Clear Naming ✅ Passed PASS: The change stays narrowly scoped; the server only swaps the base URL source, and the JS utilities use specific helpers with the generic comparator removed.
Feature Documentation ✅ Passed Only feature doc is job-analysis-symptoms.md, which covers symptoms/triage and not the test-details URL-origin logic changed here, so no doc update was needed.
Stable And Deterministic Test Names ✅ Passed Changed tests use static titles only; dynamic values appear in test bodies, not in test names.
Test Structure And Quality ✅ Passed The PR only adds/updates Jest unit tests; no Ginkgo tests, cluster resources, Eventually/Consistently, or setup/cleanup patterns are involved.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the PR only changes a Go handler and JS unit tests, so MicroShift-specific test compatibility is not implicated.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No Ginkgo e2e tests were added; the new coverage is Jest unit tests in CompReadyUtils.test.js, and the Go change only swaps URL base selection.
Topology-Aware Scheduling Compatibility ✅ Passed Only URL-handling code in server.go and JS utils/tests changed; no manifests/controllers/scheduling constraints were modified.
Ote Binary Stdout Contract ✅ Passed Touched code is an HTTP handler and client utility/tests; no main/init/TestMain/suite setup stdout writes were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changes are a Go handler tweak and Jest unit tests in sippy-ng.
No-Weak-Crypto ✅ Passed Touched files only change URL handling; no weak crypto, custom crypto, or secret/token comparisons appear in the diff or targeted searches.
Container-Privileges ✅ Passed PR only changes Go/JS URL-handling code; no container/K8s manifest edits or privileged fields were introduced in touched files.
No-Sensitive-Data-In-Logs ✅ Passed PASS: The PR only changes URL generation/conversion; the modified handler and utility functions add no logging or sensitive-data output.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sippy-ng/src/component_readiness/CompReadyUtils.js`:
- Around line 803-815: The URL rewrite logic in convertApiUrlToUiUrl is not
covered by tests, including the special /api/component_readiness/ rewrite and
the non-/api/ direct-return branch. Add regression cases in
CompReadyUtils.test.js for convertApiUrlToUiUrl and
generateTestDetailsReportLink that verify an absolute
/api/component_readiness/test_details URL becomes the expected relative
/sippy-ng/component_readiness/test_details path, and that inputs without /api/
are returned unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 1476a717-1395-4fe6-990e-920fccf22c59

📥 Commits

Reviewing files that changed from the base of the PR and between 6961d31 and acf64ec.

📒 Files selected for processing (2)
  • pkg/sippyserver/server.go
  • sippy-ng/src/component_readiness/CompReadyUtils.js

Comment thread sippy-ng/src/component_readiness/CompReadyUtils.js
…ReportLink

Addresses CodeRabbit review feedback requesting test coverage for the URL
rewrite logic that converts API URLs to UI-relative paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2026
@smg247

smg247 commented Jun 26, 2026

Copy link
Copy Markdown
Member

/lgtm
/hold cancel

@openshift-ci openshift-ci Bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 26, 2026
@openshift-ci

openshift-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: openshift-trt-agent[bot], smg247

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@openshift-merge-bot openshift-merge-bot Bot merged commit fe37833 into openshift:main Jun 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants