Skip to content

fix: include request URL in prompt variable extraction#6412

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

fix: include request URL in prompt variable extraction#6412
bijin-bruno merged 1 commit intousebruno:mainfrom
Pragadesh-45:fix/6405

Conversation

@Pragadesh-45
Copy link
Contributor

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

fixes: #6405

Summary by CodeRabbit

  • New Features
    • Variables from request URLs are now recognized and available for use in prompts across the application, extending the sources of variables considered when prompting.

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

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

  • New Features

    • Request URLs now support prompt variables, enabling dynamic configuration of ports and other URL components. Users will be prompted to enter these values when executing requests.
  • Tests

    • Expanded test coverage for prompt variable extraction and interpolation in request URLs.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

This PR fixes a bug where prompt variables embedded in the request URL (path and port) were not being extracted as prompt variables. The fix adds URL-based variable extraction logic to the Redux action handler, with corresponding test updates to verify the behavior.

Changes

Cohort / File(s) Summary
Main Logic Fix
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
Added extraction of prompt variables from request.url in extractPromptVariablesForRequest function to capture variables in the URI before GET parameter parsing.
Test Updates
tests/interpolation/prompt-variables/fixtures/collection/http-folder/http-request-without-ca.bru
Updated HTTP request URL to use variable-driven port placeholder {{?Enter Port Variable}} instead of hard-coded port 8081.
Test Spec
tests/interpolation/prompt-variables/http-request-prompt-variables.spec.ts
Incremented prompt variable field count from 11 to 12 and added initialization step for the new "Enter Port Variable" input field.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the URL extraction logic executes before GET parameter parsing to prevent variables from being misclassified as query parameters
  • Confirm the extraction handles both path and port variable scenarios without edge case regressions
  • Validate test fixture and spec updates comprehensively cover the reported bug scenario

Suggested labels

size/M

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno

Poem

🎯 Variables hiding in ports and paths,
Now prompt-extracted through proper math,
No more GET params in disguise,
The URI speaks with truth, not lies! 🚀

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 describes the main change: extracting prompt variables from request URLs to fix the issue where they were being misparsed as GET parameters.
Linked Issues check ✅ Passed The changes directly address issue #6405 by extracting prompt variables from request.url, which enables proper recognition and prompting of variables in URI path segments.
Out of Scope Changes check ✅ Passed All changes align with the objective: the core fix targets prompt variable extraction, test fixture updates validate the fix, and test count adjustments reflect the new prompt variable being tested.
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 c11d006 and d612889.

📒 Files selected for processing (3)
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (1 hunks)
  • tests/interpolation/prompt-variables/fixtures/collection/http-folder/http-request-without-ca.bru (1 hunks)
  • tests/interpolation/prompt-variables/http-request-prompt-variables.spec.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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() not func ()
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:

  • tests/interpolation/prompt-variables/http-request-prompt-variables.spec.ts
tests/**/**.*

⚙️ CodeRabbit configuration file

tests/**/**.*: Review the following e2e test code written using the Playwright test library. Ensure that:

  • Follow best practices for Playwright code and e2e automation

  • Try to reduce usage of page.waitForTimeout(); in code unless absolutely necessary and the locator cannot be found using existing expect() playwright calls

  • Avoid using page.pause() in code

  • Use locator variables for locators

  • Avoid using test.only

  • Use multiple assertions

  • Promote the use of test.step as much as possible so the generated reports are easier to read

  • Ensure that the fixtures like the collections are nested inside the fixtures folder

    Fixture Example*: Here's an example of possible fixture and test pair

    .
    ├── fixtures
    │   └── collection
    │       ├── base.bru
    │       ├── bruno.json
    │       ├── collection.bru
    │       ├── ws-test-request-with-headers.bru
    │       ├── ws-test-request-with-subproto.bru
    │       └── ws-test-request.bru
    ├── connection.spec.ts # <- Depends on the collection in ./fixtures/collection
    ├── headers.spec.ts
    ├── persistence.spec.ts
    ├── variable-interpolation
    │   ├── fixtures
    │   │   └── collection
    │   │       ├── environments
    │   │       ├── bruno.json
    │   │       └── ws-interpolation-test.bru
    │   ├── init-user-data
    │   └── variable-interpolation.spec.ts # <- Depends on the collection in ./variable-interpolation/fixtures/collection
    └── subproto.spec.ts
    

Files:

  • tests/interpolation/prompt-variables/http-request-prompt-variables.spec.ts
  • tests/interpolation/prompt-variables/fixtures/collection/http-folder/http-request-without-ca.bru
🔇 Additional comments (3)
tests/interpolation/prompt-variables/http-request-prompt-variables.spec.ts (2)

35-35: LGTM! Count correctly updated for the new port variable.

The increase from 11 to 12 prompt variables aligns with the addition of {{?Enter Port Variable}} in the fixture URL.


49-49: LGTM! Port variable fill added correctly.

The value "8081" matches the previously hardcoded port, and the positioning before other variables follows the URL structure order logically.

tests/interpolation/prompt-variables/fixtures/collection/http-folder/http-request-without-ca.bru (1)

8-8: LGTM! URL now correctly tests prompt variable extraction from port.

This change validates the fix for issue #6405, where prompt variables in the URL (specifically in the port segment) were not being recognized. The replacement of hardcoded 8081 with {{?Enter Port Variable}} directly tests the PR's objective.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

Copy link
Collaborator

@bijin-bruno bijin-bruno left a comment

Choose a reason for hiding this comment

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

Please also update the existing e2e to include a prompt variable in the url.


const prompts = extractPromptVariables(requestObj);
prompts.push(...extractPromptVariables(allVariables));
prompts.push(...extractPromptVariables(request.url));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we don't need it here. requestObj should already have url included.
Same applies for electron

@bijin-bruno bijin-bruno merged commit 71cf1a8 into usebruno:main Dec 15, 2025
8 checks passed
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.

Prompt Variables in URI are parsed as GET Parameters

2 participants