feat: enable variable interpolation in URL field for code generation#6394
feat: enable variable interpolation in URL field for code generation#6394Pragadesh-45 wants to merge 2 commits intousebruno:mainfrom
Conversation
WalkthroughAdds URL interpolation and normalization to the code-snippet generator and hardens URL utils with input guards; expands tests to cover interpolation of path params that reference collection variables. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (CODING_STANDARDS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-12-17T21:41:24.730ZApplied to files:
🧬 Code graph analysis (1)packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (2)
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/bruno-app/src/utils/url/index.js (1)
101-164: Add input guards/defaults to prevent crashes whenurl/paramsare missing.
Right nowinterpolateUrlPathParams()will throw ifurlisundefined(e.g.,interpolateUrl()returnsundefined) or ifparamsis not an array.-export const interpolateUrlPathParams = (url, params, variables) => { +export const interpolateUrlPathParams = (url, params = [], variables) => { + if (!url || typeof url !== 'string') { + return url; + } + const originalUrl = url; const getInterpolatedBasePath = (pathname, params) => { return pathname .split('/') .map((segment) => { // traditional path parameters if (segment.startsWith(':')) { const name = segment.slice(1); const pathParam = params.find((p) => p?.name === name && p?.type === 'path'); if (pathParam) { - const value = variables ? interpolate(pathParam.value, variables) : pathParam.value; - return value; + const value = variables ? interpolate(pathParam.value, variables) : pathParam.value; + return value ?? segment; } return segment; } @@ try { uri = new URL(url); } catch (error) { // if the URL is invalid, return the URL as is - return url; + return originalUrl; } @@ - return `${uri.origin}${basePath}${uri?.search || ''}`; + return `${uri.origin}${basePath}${uri?.search || ''}${uri?.hash || ''}`; };packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/index.js (1)
90-100: Guard againstinterpolatedUrlbeingundefinedbefore path-param interpolation.
interpolateUrl()can returnundefined(non-string/empty), so passing it through can break this flow (or show “Invalid URL: undefined”).- const interpolatedUrl = interpolateUrl({ + const interpolatedUrl = interpolateUrl({ url: requestData.url, variables - }); + }) || requestData.url; // interpolate the path params const finalUrl = interpolateUrlPathParams( interpolatedUrl, requestData.params, variables );
🧹 Nitpick comments (2)
packages/bruno-app/src/utils/url/index.js (1)
110-143: Consider honoringenabledfor path params (if the data model expects it).
You already checkp?.type === 'path, but if disabled params exist, this will still interpolate them.packages/bruno-app/src/utils/url/index.spec.js (1)
352-385: Optional: add a variables-based test for OData-style(:param)segments.
This would lock in the new interpolation path for the parentheses case too.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/index.js(1 hunks)packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js(1 hunks)packages/bruno-app/src/utils/url/index.js(3 hunks)packages/bruno-app/src/utils/url/index.spec.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/utils/url/index.spec.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/index.jspackages/bruno-app/src/utils/url/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
🧠 Learnings (1)
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Applied to files:
packages/bruno-app/src/utils/url/index.spec.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
🧬 Code graph analysis (2)
packages/bruno-app/src/utils/url/index.spec.js (1)
packages/bruno-app/src/utils/url/index.js (2)
interpolateUrlPathParams(101-164)interpolateUrlPathParams(101-164)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (2)
result(43-43)generateSnippet(7-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: SSL Tests - macOS
- GitHub Check: SSL Tests - Linux
- GitHub Check: Unit Tests
- GitHub Check: CLI Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: SSL Tests - Windows
🔇 Additional comments (1)
packages/bruno-app/src/utils/url/index.spec.js (1)
352-385: Nice coverage for the newvariablesbehavior (with and without variables).
These tests directly validate the new signature + interpolation semantics.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
🧠 Learnings (1)
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Applied to files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - Linux
- GitHub Check: SSL Tests - macOS
- GitHub Check: Unit Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
713d945 to
1b07773
Compare
1b07773 to
f1b4295
Compare
05e131d to
26c5fe1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.jspackages/bruno-app/src/utils/url/index.jspackages/bruno-app/src/utils/url/index.spec.js
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/bruno-app/src/utils/url/index.spec.js
- packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
- packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/index.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/utils/url/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.
Applied to files:
packages/bruno-app/src/utils/url/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (1)
packages/bruno-app/src/utils/url/index.js (2)
interpolateUrlPathParams(101-174)interpolateUrlPathParams(101-174)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: SSL Tests - macOS
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - Linux
- GitHub Check: Unit Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
🔇 Additional comments (8)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (3)
5-5: LGTM!Import added correctly to support path parameter interpolation.
15-15: Good defensive programming!Creating a shallow copy prevents mutation of the original
item.requestobject, which is the correct approach here.
28-35: LGTM!Path parameter interpolation is correctly integrated into the interpolation flow. The ordering (path params → headers → body) is logical and the implementation properly passes variables through the interpolation chain.
packages/bruno-app/src/utils/url/index.js (5)
101-104: Good input validation!Adding defensive checks for falsy or non-string URLs prevents potential errors downstream.
107-109: Good optimization!Early return when no path params are enabled avoids unnecessary URL parsing and processing.
120-124: LGTM!The interpolation logic correctly handles both variable-based and direct value substitution, with proper fallback to the original segment when values are missing.
148-150: LGTM!OData-style parameter interpolation correctly mirrors the traditional path param logic with proper variable support.
173-173: Good fix!Including the hash fragment ensures the complete URL is preserved during interpolation, addressing the requirement from the commit message.
| // If there are no enabled path params, return the URL as-is to avoid URL encoding side | ||
| const hasPathParams = params.some((p) => p?.type === 'path' && p?.enabled); | ||
| if (!hasPathParams) { | ||
| return url; | ||
| } |
There was a problem hiding this comment.
Fix the incomplete comment.
The comment "to avoid URL encoding side" appears incomplete. Consider: "to avoid URL encoding side effects" or "to avoid unnecessary URL encoding".
🔎 Suggested fix
- // If there are no enabled path params, return the URL as-is to avoid URL encoding side
+ // If there are no enabled path params, return the URL as-is to avoid unnecessary URL encoding🤖 Prompt for AI Agents
In packages/bruno-app/src/utils/url/index.js around lines 106 to 110, the inline
comment "to avoid URL encoding side" is incomplete; update it to a clear,
complete phrase such as "to avoid URL encoding side effects" or "to avoid
unnecessary URL encoding" so the intent is unambiguous (replace the current
comment text only; no code changes).
| // Interpolate headers, body and path params if needed | ||
| if (shouldInterpolate) { | ||
| // Interpolate path parameters | ||
| request.url = interpolateUrlPathParams( |
There was a problem hiding this comment.
Per current implementation,
- I think the
interpolateUrlPathParamsshouldn't be done here since it is expected to be resolved already from the parent componentGenerateCodeItem. - Considering the above fact, variable interpolation shouldn't happen inside
interpolateUrlPathParamssince it should respect the setting calledshouldInterpolate.interpolateUrlPathParamsshould only interpolate the path params. - I think we should revert other changes in this PR and just do interpolateUrl here.
request.url = interpolateUrl(request.url, variables);
26c5fe1 to
e37ab4a
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js (1)
430-477: Well-structured test for issue #6365.The test properly validates that the snippet generator interpolates collection variables in URLs. The explanatory comment (lines 431-433) clearly documents the design decision to test the snippet generator's responsibility in isolation.
Optional: Consider more precise assertion
The current assertions using
toContainare sufficient, but you could make them more precise by checking the exact output:- // The URL should have the interpolated variable value - expect(result).toContain('https://api.example.com/en'); - // And not contain the variable placeholder - expect(result).not.toContain('{{current_language}}'); + expect(result).toBe('curl -X GET https://api.example.com/en');This matches the pattern used in other tests and validates the complete output structure.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.jspackages/bruno-app/src/utils/url/index.jspackages/bruno-app/src/utils/url/index.spec.js
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/bruno-app/src/utils/url/index.spec.js
- packages/bruno-app/src/utils/url/index.js
- packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
🧠 Learnings (3)
📚 Learning: 2025-12-16T07:16:23.647Z
Learnt from: sanish-bruno
Repo: usebruno/bruno PR: 6090
File: tests/scripting/hooks/init-user-data/ui-state-snapshot.json:1-8
Timestamp: 2025-12-16T07:16:23.647Z
Learning: For e2e tests in the bruno repository: Collections that are shared between CLI and UI tests (comprehensive test suites testing core functionality) should be placed in `packages/bruno-tests/` to avoid duplication. The `tests/**/fixtures/collection` pattern should be used for test-specific collections that test particular UI behaviors or are specific to a single test file.
Applied to files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created
Applied to files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.
Applied to files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (2)
result(46-46)generateSnippet(8-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
- GitHub Check: Unit Tests
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - Linux
- GitHub Check: SSL Tests - macOS
🔇 Additional comments (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js (1)
153-153: LGTM! Test expectations correctly updated for URL interpolation.The updated assertions properly reflect that
generateSnippetnow interpolates variables in URLs whenshouldInterpolateis true. The changes are consistent across all affected tests and align with the new functionality.Also applies to: 210-210, 272-272, 378-378
| } | ||
|
|
||
| // If there are no params or no enabled path params, return the URL as-is | ||
| if (!params || !params.length) { |
There was a problem hiding this comment.
Though this is not the right place to do the url encoding, it seems like this method interpolateUrlPathParams is also doing the encoding job at the code block 156 to 171 as below.
let uri;
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = `http://${url}`;
}
try {
uri = new URL(url);
} catch (error) {
// if the URL is invalid, return the URL as is
return url;
}
const basePath = getInterpolatedBasePath(uri.pathname, params);
return `${uri.origin}${basePath}${uri?.search || ''}`;So without moving the encoding task out of this method, we cannot place these safety checks here since the encoding will break when there is no params included.
…st handling in snippet generation
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (1)
28-40: Past review feedback addressed; guard against undefined URL.The implementation now correctly uses
interpolateUrland respects theshouldInterpolatesetting as suggested by bijin-bruno's earlier review. The order of operations (interpolate → normalize → headers/body) is logical.However,
interpolateUrlcan returnundefinedif the URL is falsy, empty, or not a string (seeutils/url/index.js:92-98). If this occurs,request.urlwould be set toundefined, potentially breakingbuildHarRequestdownstream.🔎 Proposed guard for undefined return
// Interpolate URL, headers, and body if needed if (shouldInterpolate) { - request.url = interpolateUrl({ url: request.url, variables }); + const interpolatedUrl = interpolateUrl({ url: request.url, variables }); + if (interpolatedUrl !== undefined) { + request.url = interpolatedUrl; + } // Normalize and encode URL to ensure consistent encoding // This must happen after variable interpolation but before buildHarRequest request.url = normalizeAndEncodeUrl(request.url); headers = interpolateHeaders(headers, variables); if (request.body) { request.body = interpolateBody(request.body, variables); } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.jspackages/bruno-app/src/utils/url/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bruno-app/src/utils/url/index.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.
Applied to files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (1)
packages/bruno-app/src/utils/url/index.js (4)
interpolateUrl(93-99)interpolateUrl(93-99)normalizeAndEncodeUrl(101-129)normalizeAndEncodeUrl(101-129)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Unit Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: SSL Tests - Linux
- GitHub Check: CLI Tests
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - macOS
🔇 Additional comments (2)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js (2)
5-5: LGTM: Import statements are correct.The imports for URL interpolation and normalization utilities are properly added and match their usage in the interpolation block.
15-15: Good defensive practice.Creating a shallow copy prevents mutation of the original request object, which is appropriate for the top-level property modifications made in this function.
fixes: #6365
Description
This PR introduces support for variable interpolation in the URL field during code generation. This allows dynamic values to be inserted into URLs, enabling more flexible and customizable code generation processes. With this feature, users can now define variables in the URL field that get replaced with actual values at runtime
Contribution Checklist:
Before:


After:

Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.