Skip to content

OCPBUGS-99942: Fix missing query params in Prometheus API requests - #1124

Open
gauron99 wants to merge 1 commit into
openshift:mainfrom
gauron99:push-uktpryvlzwuq
Open

OCPBUGS-99942: Fix missing query params in Prometheus API requests#1124
gauron99 wants to merge 1 commit into
openshift:mainfrom
gauron99:push-uktpryvlzwuq

Conversation

@gauron99

@gauron99 gauron99 commented Aug 12, 2026

Copy link
Copy Markdown

Claude analysis

Replace params.size > 0 with params.toString() check in buildPrometheusUrl. URLSearchParams.size is
unsupported in older browsers (pre-Chrome 113, pre-Firefox 112, pre-Safari 17), causing query parameters
to be silently dropped and Thanos to return 400.

https://caniuse.com/mdn-api_urlsearchparams_size

Affected versions: OCP 4.19 through current.

  • 4.19-4.22: web/src/components/utils.ts
  • 4.23+: web/src/shared/utils/utils.ts
  • 4.18 and earlier: not affected.

Verification

Headless Chrome test with URLSearchParams.prototype.size overridden to undefined:

  • Old code (params.size > 0): returns empty string, query params dropped
  • New code (params.toString()): returns ?query=up&start=123&end=456&step=30

Summary by CodeRabbit

  • Bug Fixes
    • Improved URL generation for Prometheus queries, including cleaner handling when no search parameters are present.

Replace params.size > 0 with params.toString() check in
buildPrometheusUrl. URLSearchParams.size is unsupported in older
browsers (pre-Chrome 113, pre-Firefox 112, pre-Safari 17), causing
query parameters to be silently dropped and Thanos to return 400.
@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: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 12, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@gauron99: This pull request references Jira Issue OCPBUGS-99942, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Claude analysis

Replace params.size > 0 with params.toString() check in buildPrometheusUrl. URLSearchParams.size is
unsupported in older browsers (pre-Chrome 113, pre-Firefox 112, pre-Safari 17), causing query parameters
to be silently dropped and Thanos to return 400.

https://caniuse.com/mdn-api_urlsearchparams_size

Affected versions: OCP 4.19 through current.

  • 4.19-4.22: web/src/components/utils.ts
  • 4.23+: web/src/shared/utils/utils.ts
  • 4.18 and earlier: not affected.

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 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gauron99
Once this PR has been reviewed and has the lgtm label, please assign zhuje for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Walkthrough

buildPrometheusUrl now serializes search parameters once and appends the query delimiter only when the serialized string is non-empty.

Changes

Prometheus URL construction

Layer / File(s) Summary
Conditional query string construction
web/src/shared/utils/utils.ts
buildPrometheusUrl stores the serialized search parameters in queryString and uses its presence to conditionally append the query string.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: peteryurkovich

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Stable And Deterministic Test Names ✅ Passed The diff changes only buildPrometheusUrl in a utility source file; it adds no Ginkgo test declarations or test titles.
Test Structure And Quality ✅ Passed The PR changes only web/src/shared/utils/utils.ts; no Ginkgo test files or It blocks are added or modified, so the test-structure requirements are not applicable.
Microshift Test Compatibility ✅ Passed The diff changes only TypeScript URL construction in web/src/shared/utils/utils.ts; it adds no Ginkgo e2e tests, so MicroShift test compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR changes only web/src/shared/utils/utils.ts and adds no Ginkgo e2e tests or multi-node assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The pull request changes only web/src/shared/utils/utils.ts and introduces no deployment, operator, controller, or scheduling changes.
Ote Binary Stdout Contract ✅ Passed The pull request changes only TypeScript URL construction; it does not modify OTE binaries or process-level Go stdout behavior.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The pull request changes only a TypeScript URL utility; it adds no Ginkgo e2e tests, IPv4 assumptions, or external connectivity requirements.
No-Weak-Crypto ✅ Passed The only changed file updates URLSearchParams serialization in buildPrometheusUrl; the patch introduces no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The patch changes only URL query-string handling in TypeScript. No container/Kubernetes manifest or privilege-related setting was added.
No-Sensitive-Data-In-Logs ✅ Passed The diff only changes URLSearchParams serialization in buildPrometheusUrl; it adds no logging or sensitive-data output, and the utility contains no logging calls.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the bug and the main change: fixing missing query parameters in Prometheus API requests.
✨ 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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
web/src/shared/utils/utils.ts (1)

272-273: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for this browser-compatibility fix.

Add or update web/src/shared/utils/utils.spec.ts to verify that non-empty parameters append ? and serialized parameters, while empty parameters append neither. This protects the fix against regressions.

As per coding guidelines, “**/*.{ts,tsx,go}: Add unit tests for utility functions, business logic, bug fixes, and backend API handlers.”

🤖 Prompt for 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.

In `@web/src/shared/utils/utils.ts` around lines 272 - 273, Add regression
coverage in the utility tests for the URL-building logic around
params.toString(): verify non-empty parameters produce a query string prefixed
with “?” and empty parameters produce neither a question mark nor serialized
parameters. Update web/src/shared/utils/utils.spec.ts using the existing test
conventions.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@web/src/shared/utils/utils.ts`:
- Around line 272-273: Add regression coverage in the utility tests for the
URL-building logic around params.toString(): verify non-empty parameters produce
a query string prefixed with “?” and empty parameters produce neither a question
mark nor serialized parameters. Update web/src/shared/utils/utils.spec.ts using
the existing test conventions.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 4fcc1405-c0a2-4708-bd6e-a2282b4cfb0b

📥 Commits

Reviewing files that changed from the base of the PR and between 4871cd7 and 98bcc7a.

📒 Files selected for processing (1)
  • web/src/shared/utils/utils.ts

@gauron99

Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 12, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@gauron99: This pull request references Jira Issue OCPBUGS-99942, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@gauron99: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@PeterYurkovich

Copy link
Copy Markdown
Contributor

@gauron99 Could you please define where the need to support browsers that are more than 3 years old is coming from? If it is a requirement for UI teams, then our team will need to add other polyfills and testing to ensure compliance

@gauron99

Copy link
Copy Markdown
Author

Hi, we are waiting to hear back about the CU browser version. I just prepped this PR for the case as it fixed my issue. @PeterYurkovich

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

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants