fix: prevent colons in OData datetime values from being parsed as path parameters#7388
Conversation
…nd underscore characters
WalkthroughURL path parameter parsing is refined across four files to treat colons as parameter delimiters only when followed by identifier-compliant names (starting with a letter or underscore). This prevents datetime expressions in OData-style URLs from being incorrectly parsed as path parameters. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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)
packages/bruno-cli/src/runner/interpolate-vars.js (1)
130-169: Consider extracting shared OData path interpolation logic.The OData path parameter parsing block (lines 130-169) is nearly identical to
packages/bruno-electron/src/ipc/network/interpolate-vars.js(lines 154-206). If this logic evolves, keeping them in sync could become error-prone. A shared utility in@usebruno/commoncould reduce duplication.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/bruno-cli/src/runner/interpolate-vars.js` around lines 130 - 169, The OData-style path interpolation logic inside the interpolatedUrlPath mapping is duplicated elsewhere — extract it into a shared utility (e.g., create a function interpolateODataPath(pathSegment, pathParams) in `@usebruno/common`) that encapsulates the regex check (/^[A-Za-z0-9_.-]+\([^)]*\)$/), the paramRegex handling, and replacement using request.pathParams (or the passed pathParams array); then replace the in-file block that uses paramRegex, match loop, and result replacement with a call to that utility from both this module (where interpolatedUrlPath is built) and the other consumer to avoid duplication and keep behavior identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/bruno-cli/src/runner/interpolate-vars.js`:
- Around line 130-169: The OData-style path interpolation logic inside the
interpolatedUrlPath mapping is duplicated elsewhere — extract it into a shared
utility (e.g., create a function interpolateODataPath(pathSegment, pathParams)
in `@usebruno/common`) that encapsulates the regex check
(/^[A-Za-z0-9_.-]+\([^)]*\)$/), the paramRegex handling, and replacement using
request.pathParams (or the passed pathParams array); then replace the in-file
block that uses paramRegex, match loop, and result replacement with a call to
that utility from both this module (where interpolatedUrlPath is built) and the
other consumer to avoid duplication and keep behavior identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9cf29f34-0c31-469d-bee0-2bda18df0894
📒 Files selected for processing (4)
packages/bruno-app/src/utils/url/index.jspackages/bruno-app/src/utils/url/index.spec.jspackages/bruno-cli/src/runner/interpolate-vars.jspackages/bruno-electron/src/ipc/network/interpolate-vars.js
Description
Closes #7384
JIRA
Bug
For the URL:
https://api10.successfactors.com/odata/v2/EmpJob(seqNumber=1L,startDate=datetime'2021-08-29T00:00:00',userId='213668')?$format=jsonThe regex /:/g matched :00 from the time string T00:00:00 as a path parameter named 00. During interpolation, these were replaced with empty values, corrupting the URL to:
datetime'2021-08-29T00Fix
Path parameter names are identifiers (:userId, :orderId) — they always start with a letter or underscore, never a digit. The updated regex /:/g enforces this, so :00 in datetime strings is ignored while :userId is still correctly detected.
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
Bug Fixes
Tests