Skip to content

feat: Streamline gRPC requests to use right context#6308

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
Pragadesh-45:fix/6254
Dec 4, 2025
Merged

feat: Streamline gRPC requests to use right context#6308
bijin-bruno merged 1 commit intousebruno:mainfrom
Pragadesh-45:fix/6254

Conversation

@Pragadesh-45
Copy link
Contributor

@Pragadesh-45 Pragadesh-45 commented Dec 4, 2025

Jira
fixes: #6254

Description

Streamline gRPC requests to use right context

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • Bug Fixes
    • Interpolation now respects collection-, folder-, and request-level variables so templates resolve more consistently.
    • URL handling preserves templated URLs and only auto-prepends a protocol for plain URLs.
    • Environment, certificate, and proxy values are correctly applied for gRPC requests and related network configuration.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

Adds collection-, folder-, and request-level variable sources into string interpolation and wires them into certificate/proxy interpolation; gRPC IPC handlers normalize missing URL protocol and pass preparedRequest to cert/proxy resolution; request URL normalization now preserves templated URLs ({{...}}).

Changes

Cohort / File(s) Summary
Variable interpolation foundation
packages/bruno-electron/src/ipc/network/interpolate-string.js
Expanded interpolateString signature to accept collectionVariables, folderVariables, and requestVariables (default {}) and merged them into the combined variables used for interpolation; adjusted precedence.
Certificate & proxy interpolation
packages/bruno-electron/src/ipc/network/cert-utils.js
Initializes collectionVariables, folderVariables, and requestVariables (default {}) and includes them in interpolationOptions passed to certificate/proxy resolution functions.
gRPC IPC handlers
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js
Adds protocol detection and prefixes preparedRequest.url with http:// when no scheme is present; passes preparedRequest into getCertsAndProxyConfig and merges collection-scoped variables during request preparation.
Request configuration / URL handling
packages/bruno-electron/src/ipc/network/index.js
configureRequest detects templated URLs (starting with {{) and avoids prepending http:// for templated URLs; preserves prior normalization for non-templated URLs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect variable merging and precedence in interpolate-string.js for unintended overrides.
  • Verify all interpolation call sites in cert-utils.js receive the added variable sets.
  • Confirm gRPC protocol detection in grpc-event-handlers.js handles existing schemes and edge cases (e.g., IPv6 literals, templated hosts).
  • Validate configureRequest template detection doesn't skip normalization for legitimate URLs that incidentally start with {{ in edge scenarios.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno

Poem

Collection, folder, request conspire,
Templates kept while schemes acquire,
Variables flow into cert and proxy art—
Prepared requests ready to depart,
Small changes, smoother parts ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective: streamlining gRPC requests to use the correct context by resolving variables before URL normalization.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #6254: URL protocol normalization now occurs after variable resolution, preventing malformed URLs like http://https://apiendpoint.com/.
Out of Scope Changes check ✅ Passed All changes are scoped to the gRPC request handling pipeline and variable interpolation necessary to resolve issue #6254; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac8656 and b87a02b.

📒 Files selected for processing (4)
  • packages/bruno-electron/src/ipc/network/cert-utils.js (1 hunks)
  • packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (3 hunks)
  • packages/bruno-electron/src/ipc/network/index.js (1 hunks)
  • packages/bruno-electron/src/ipc/network/interpolate-string.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/bruno-electron/src/ipc/network/cert-utils.js
  • packages/bruno-electron/src/ipc/network/grpc-event-handlers.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, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-electron/src/ipc/network/interpolate-string.js
  • packages/bruno-electron/src/ipc/network/index.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 - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
🔇 Additional comments (3)
packages/bruno-electron/src/ipc/network/index.js (1)

112-115: Reasonable heuristic for the linked issue.

The startsWith('{{') check handles the common case where a base URL variable like {{baseUrl}} resolves to include the protocol (e.g., https://example.com).

Note: This won't catch URLs like api.{{domain}}/path where variables appear mid-URL but don't affect the protocol. That said, it's an acceptable trade-off for fixing the primary issue.

packages/bruno-electron/src/ipc/network/interpolate-string.js (2)

4-24: Clean extension of the interpolation function.

The added variable sources (collectionVariables, folderVariables, requestVariables) are properly initialized and follow a sensible precedence hierarchy from global → collection → folder → request.


42-55: Precedence order looks correct.

The merge order ensures request-level variables override folder, folder overrides collection, etc. This matches typical variable resolution expectations.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (1)

184-197: Same double merge issue as in grpc:start-connection.

This handler repeats the problematic pattern from lines 40-52, resulting in duplicate variable merging and code duplication.

Apply the same fix as suggested for the previous handler.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9ce97f and 633c55b.

📒 Files selected for processing (4)
  • packages/bruno-electron/src/ipc/network/cert-utils.js (1 hunks)
  • packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (4 hunks)
  • packages/bruno-electron/src/ipc/network/index.js (1 hunks)
  • packages/bruno-electron/src/ipc/network/interpolate-string.js (2 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, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-electron/src/ipc/network/cert-utils.js
  • packages/bruno-electron/src/ipc/network/grpc-event-handlers.js
  • packages/bruno-electron/src/ipc/network/index.js
  • packages/bruno-electron/src/ipc/network/interpolate-string.js
🧬 Code graph analysis (2)
packages/bruno-electron/src/ipc/network/cert-utils.js (3)
packages/bruno-electron/src/ipc/network/index.js (4)
  • collectionVariables (303-303)
  • collection (146-146)
  • requestVariables (302-302)
  • request (326-326)
packages/bruno-cli/src/utils/collection.js (3)
  • collectionVariables (159-159)
  • folderVariables (166-166)
  • requestVariables (167-167)
packages/bruno-electron/src/ipc/network/interpolate-vars.js (3)
  • collectionVariables (24-24)
  • folderVariables (25-25)
  • requestVariables (26-26)
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (3)
packages/bruno-electron/src/ipc/network/prepare-grpc-request.js (3)
  • requestTreePath (24-24)
  • collection (21-21)
  • prepareGrpcRequest (16-122)
packages/bruno-electron/src/utils/collection.js (2)
  • getTreePathFromCollectionToItem (239-247)
  • mergeVars (52-98)
packages/bruno-cli/src/utils/collection.js (2)
  • getTreePathFromCollectionToItem (333-341)
  • mergeVars (155-201)
⏰ 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: Playwright E2E Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
🔇 Additional comments (4)
packages/bruno-electron/src/ipc/network/cert-utils.js (1)

50-59: LGTM on interpolationOptions structure.

Once the variable initialization is corrected, this properly wires the new variable sources into the interpolation context for certificate and proxy configuration.

packages/bruno-electron/src/ipc/network/index.js (1)

112-114: LGTM on URL normalization guard.

The hasVariables check prevents protocol normalization for templated URLs, preserving them for later interpolation. The implementation is straightforward and aligns with the PR objectives.

packages/bruno-electron/src/ipc/network/interpolate-string.js (2)

4-14: LGTM on expanded function signature.

The destructured parameters cleanly expose all variable sources for interpolation.


19-56: LGTM on variable initialization and merging.

The new variable sources are properly initialized with defaults and merged into combinedVars with the correct precedence order. The implementation is consistent with the existing pattern.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (1)

39-42: Avoid duplicating protocol normalization logic in three handlers

The same protocolRegex and http:// prefixing logic is repeated in all three handlers (start-connection, load-methods-reflection, and generate-grpcurl). Centralising this (either as a shared top‑level helper/constant in this module or inside prepareGrpcRequest) would keep URL rules consistent and reduce future maintenance overhead if the normalization rules evolve again.

Also applies to: 176-180, 287-290

🧹 Nitpick comments (1)
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (1)

287-290: Extend grpcurl interpolation options to use new variable sources

In grpc:generate-grpcurl, interpolationOptions only includes envVars, runtimeVariables, and processEnvVars, so the new variable categories supported by interpolateString (e.g. collection‑, folder‑, request‑, and global environment variables / prompt variables) are not used when resolving clientCert.domain, certFilePath, and keyFilePath. That means grpcurl’s certificate path interpolation is now less capable than the main cert/proxy flow via getCertsAndProxyConfig.

Consider expanding interpolationOptions here to pass through the same variable sets that getCertsAndProxyConfig is using, so domain and path templates behave consistently across request execution and grpcurl generation. While you’re here, double‑check that the host‑matching regex in this block stays in sync with the scheme you now normalize to (http:// when missing), or relax the scheme matching so that normalized URLs still match configured domains.

Also applies to: 292-296, 303-320

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 293db05 and 56d3795.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (3 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, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-electron/src/ipc/network/grpc-event-handlers.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (3)
packages/bruno-electron/src/ipc/network/index.js (4)
  • protocolRegex (111-111)
  • certsAndProxyConfig (117-126)
  • certsAndProxyConfig (147-147)
  • collection (146-146)
packages/bruno-electron/src/ipc/network/cert-utils.js (2)
  • getCertsAndProxyConfig (12-126)
  • collection (44-44)
packages/bruno-electron/src/ipc/network/prepare-grpc-request.js (1)
  • collection (21-21)
⏰ 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: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
🔇 Additional comments (1)
packages/bruno-electron/src/ipc/network/grpc-event-handlers.js (1)

45-53: Passing preparedRequest into getCertsAndProxyConfig looks correct

Routing preparedRequest (rather than the raw request) into getCertsAndProxyConfig ensures certificate/proxy configuration is based on the fully prepared URL and variable-expanded fields, which matches how HTTP request configuration is wired elsewhere and should make cert selection more reliable.

Also applies to: 182-191

@Pragadesh-45 Pragadesh-45 changed the title feat: enhance request handling with variable merging and URL normalization feat: Streamline gRPC requests to use right context Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collection Runner adds http:// to all requests

3 participants