OCPBUGS-99942: Fix missing query params in Prometheus API requests - #1124
OCPBUGS-99942: Fix missing query params in Prometheus API requests#1124gauron99 wants to merge 1 commit into
Conversation
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.
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@gauron99: This pull request references Jira Issue OCPBUGS-99942, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gauron99 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Walkthrough
ChangesPrometheus URL construction
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ 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.
🧹 Nitpick comments (1)
web/src/shared/utils/utils.ts (1)
272-273: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a regression test for this browser-compatibility fix.
Add or update
web/src/shared/utils/utils.spec.tsto 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
📒 Files selected for processing (1)
web/src/shared/utils/utils.ts
|
/jira refresh |
|
@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
DetailsIn response to this:
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. |
|
@gauron99: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
@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 |
|
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 |
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.
Verification
Headless Chrome test with
URLSearchParams.prototype.sizeoverridden toundefined:params.size > 0): returns empty string, query params droppedparams.toString()): returns?query=up&start=123&end=456&step=30Summary by CodeRabbit