Skip to content

fix(import): Import fails for gRPC request without URL in exported collection#8367

Open
sharan-bruno wants to merge 4 commits into
usebruno:mainfrom
sharan-bruno:fix/Import-fails-for-grpc-request-without-url
Open

fix(import): Import fails for gRPC request without URL in exported collection#8367
sharan-bruno wants to merge 4 commits into
usebruno:mainfrom
sharan-bruno:fix/Import-fails-for-grpc-request-without-url

Conversation

@sharan-bruno

@sharan-bruno sharan-bruno commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Jira: https://usebruno.atlassian.net/browse/BRU-2205

Description

Fix: import fails for requests without a URL

requestUrlSchema from .defined() to .optional() so collections containing gRPC/HTTP requests with an empty URL no longer fail import with items[0].request.url must be defined. Added an E2E regression test covering both request types.

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.

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
    • Improved Bruno import behavior for HTTP and gRPC requests/examples that don’t include a URL.
    • Normalized empty/missing request URL values during import so items are retained and interpreted correctly (including request examples).
  • Tests
    • Added Playwright coverage to verify importing Bruno fixtures for missing-request-URL cases across HTTP, gRPC, and HTTP example collections.
    • Ensures imported collections appear in the UI sidebar after import.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Bruno importer now normalizes missing request URLs during request and example transformation. New HTTP and gRPC fixtures omit URLs, and a Playwright spec imports the cases and verifies the collections appear in the sidebar.

Changes

Missing-URL Bruno import flow

Layer / File(s) Summary
Request URL normalization
packages/bruno-app/src/utils/importers/common.js
transformItemsInCollection imports valueToString and applies it to request URLs for request items and request examples.
Import fixtures and spec
tests/import/bruno/fixtures/bruno-http-request-missing-url.json, tests/import/bruno/fixtures/bruno-grpc-request-missing-url.json, tests/import/bruno/fixtures/bruno-http-example-request-missing-url.json, tests/import/bruno/import-bruno-request-missing-url.spec.ts
The new HTTP, gRPC, and HTTP example fixtures omit request URLs, and the serial Playwright spec imports each case and asserts the collections appear in the sidebar.

Sequence Diagram(s)

sequenceDiagram
  participant Spec as Playwright spec
  participant Importer as importCollection
  participant Transformer as transformItemsInCollection
  participant Utility as valueToString
  participant Sidebar as buildCommonLocators
  Spec->>Importer: import HTTP, gRPC, or example fixture
  Importer->>Transformer: transform request items and examples
  Transformer->>Utility: normalize item.request.url
  Utility-->>Transformer: string value
  Transformer->>Utility: normalize example.request.url
  Utility-->>Transformer: string value
  Importer-->>Spec: imported collection
  Spec->>Sidebar: build collection selector
  Sidebar-->>Spec: sidebar locator
  Spec->>Sidebar: assert collection is visible
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno
  • sid-bruno

Poem

A URL drifted off the page,
But imports stayed neat on stage.
With valueToString in tow,
The sidebar said, “Hello!”
And tests kept time with gentle gauge.

🚥 Pre-merge checks | ✅ 5
✅ 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 clearly matches the main fix: importing exported collections with missing request URLs, especially for gRPC.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@packages/bruno-schema/src/collections/index.js`:
- Line 132: The shared request URL schema was made optional in a way that
affects all consumers, not just the intended import paths. Revert the broad
change on requestUrlSchema in collections/index.js, keep the shared schema
strict, and apply .optional() only inside the specific HTTP/gRPC request schema
builders that need URL-less imports, such as the request-type-specific schema
definitions.

In `@tests/import/bruno/import-bruno-request-missing-url.spec.ts`:
- Around line 5-30: The Bruno import tests are split across two tests that
depend on shared state and `test.describe.serial`, which makes them
non-parallel-safe. Update the `cases` loop in
`import-bruno-request-missing-url.spec.ts` so each scenario does the import and
the sidebar visibility assertion in the same `test` callback, using
`importCollection` and `buildCommonLocators` together. After inlining the
assertion, remove the serial-only dependency so each case is self-contained and
follows the Arrange-Act-Assert-Cleanup pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d84c31c0-4d79-40fb-b055-64174744439b

📥 Commits

Reviewing files that changed from the base of the PR and between 7765320 and ce69193.

📒 Files selected for processing (4)
  • packages/bruno-schema/src/collections/index.js
  • tests/import/bruno/fixtures/bruno-grpc-request-missing-url.json
  • tests/import/bruno/fixtures/bruno-http-request-missing-url.json
  • tests/import/bruno/import-bruno-request-missing-url.spec.ts

Comment thread packages/bruno-schema/src/collections/index.js Outdated
Comment thread tests/import/bruno/import-bruno-request-missing-url.spec.ts
Comment thread packages/bruno-schema/src/collections/index.js Outdated
Comment thread packages/bruno-app/src/utils/importers/common.js Outdated
Comment thread tests/import/bruno/fixtures/bruno-http-request-missing-url.json
Comment thread packages/bruno-app/src/utils/importers/common.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
tests/import/bruno/import-bruno-request-missing-url.spec.ts (1)

5-29: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Make each fixture case self-contained.

Line 26 relies on state created by Line 17, so these cases only pass because the suite is serialised. That breaks parallel-safety and makes the regression flaky. Import and sidebar assertion should live in the same test callback for each case, then test.describe.serial can go away.

Minimal rewrite
-test.describe.serial('Import Bruno Collection - request with missing URL', () => {
+test.describe('Import Bruno Collection - request with missing URL', () => {
@@
   for (const { fixture, collectionName, type } of cases) {
     test(`imports a ${type} request without a URL`, async ({ page, createTmpDir }) => {
       const brunoFile = path.resolve(__dirname, 'fixtures', fixture);
       const location = await createTmpDir(collectionName);

       await importCollection(page, brunoFile, location, {
         expectedCollectionName: collectionName
       });
-    });
-
-    test(`${type} collection appears in the sidebar after import`, async ({ page }) => {
+
       const locators = buildCommonLocators(page);
       await expect(locators.sidebar.collection(collectionName)).toBeVisible();
     });
   }
 });
#!/bin/bash
set -euo pipefail

file='tests/import/bruno/import-bruno-request-missing-url.spec.ts'

printf '\n== Suite structure ==\n'
sed -n '1,80p' "$file"

printf '\n== Shared-state indicators ==\n'
rg -n 'describe\.serial|test\(`imports a .* without a URL`|collection appears in the sidebar after import' "$file"

As per coding guidelines, “E2E tests must be parallel-safe” and “Every E2E test should follow the Arrange-Act-Assert-Cleanup shape.” As per path instructions, “Follow best practices for Playwright code and e2e automation.”

🤖 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 `@tests/import/bruno/import-bruno-request-missing-url.spec.ts` around lines 5 -
29, The Bruno import cases are split across two tests, so the sidebar assertion
depends on shared state from the import test and only works because the suite is
serial. Move the import and visibility check into the same test callback inside
the `cases` loop in `import-bruno-request-missing-url.spec.ts`, using
`importCollection` and `buildCommonLocators` together for each
`fixture`/`collectionName`/`type`, and then remove the `test.describe.serial`
wrapper so each case is self-contained and parallel-safe.

Sources: Coding guidelines, Path instructions

🤖 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.

Duplicate comments:
In `@tests/import/bruno/import-bruno-request-missing-url.spec.ts`:
- Around line 5-29: The Bruno import cases are split across two tests, so the
sidebar assertion depends on shared state from the import test and only works
because the suite is serial. Move the import and visibility check into the same
test callback inside the `cases` loop in
`import-bruno-request-missing-url.spec.ts`, using `importCollection` and
`buildCommonLocators` together for each `fixture`/`collectionName`/`type`, and
then remove the `test.describe.serial` wrapper so each case is self-contained
and parallel-safe.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0c91250b-ae6a-407a-84da-b29f41d3170e

📥 Commits

Reviewing files that changed from the base of the PR and between 6be3386 and be07e02.

📒 Files selected for processing (2)
  • tests/import/bruno/fixtures/bruno-http-example-request-missing-url.json
  • tests/import/bruno/import-bruno-request-missing-url.spec.ts

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.

2 participants