Skip to content

Comments

fix: skip null query parameters in Postman to Bruno conversion#7193

Open
sanish-bruno wants to merge 2 commits intousebruno:mainfrom
sanish-bruno:fix/pm-import-with-null-query-params
Open

fix: skip null query parameters in Postman to Bruno conversion#7193
sanish-bruno wants to merge 2 commits intousebruno:mainfrom
sanish-bruno:fix/pm-import-with-null-query-params

Conversation

@sanish-bruno
Copy link
Collaborator

@sanish-bruno sanish-bruno commented Feb 18, 2026

Jira

Summary

  • Postman collections can contain query parameters with null keys/values (e.g., {"key": null, "value": null}), which causes a crash during import: TypeError: Cannot read properties of null (reading 'includes')
  • Skip query params where both key and value are null, and normalize individual null keys/values to empty strings — matching the existing guard used for path variables
  • Applied the fix in both regular request params and response example params

Test plan

  • Added test case covering: fully-null params (skipped), null key with value (normalized), key with null value (normalized)
  • Verify existing bruno-converters tests still pass (npm run test --workspace=packages/bruno-converters)
  • Manually import a Postman collection containing null query params and confirm no crash

Description

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 handling of null query parameters in Postman collection imports to properly filter invalid entries and normalize empty values.
  • Tests

    • Added test cases validating query parameter filtering and normalization when converting Postman collections to Bruno format.

Updated the importPostmanV2CollectionItem function to skip query parameters where both key and value are null. Added a test case to ensure that such parameters are not included in the converted Bruno collection, while preserving other valid parameters.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Walkthrough

Enhances Postman-to-Bruno converter with null-safety guards for query parameters. Adds protective checks to skip entries where both key and value are null, and uses nullish coalescing to ensure defined string values in parameter assignments.

Changes

Cohort / File(s) Summary
Query Parameter Null-Safety
packages/bruno-converters/src/postman/postman-to-bruno.js
Adds guards to skip null query parameters in two processing paths. Implements nullish coalescing for name and value assignments to prevent undefined values.
Null-Safety Test Coverage
packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js
Adds test case validating filtering of null query parameters and normalization behavior (null key/value becomes empty string).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

size/XS

Suggested reviewers

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

Poem

Null guards stand sentinel at the gate,
Filtering out the empty and the null,
With coalescing shields held straight,
No undefined shall pass—the fix is full,
Postman's queries now pristine and great. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing null query parameter handling in Postman to Bruno conversion, which matches the changeset modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🧹 Nitpick comments (1)
packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js (1)

608-658: Good test — but originalRequest.url.query null-filter path is uncovered.

The test validates the fix for the main request query params (lines 535–547 in source), but the parallel null guard added to originalRequest.url.query.forEach (lines 625–631) has no corresponding test. Per coding guidelines, both code paths should be covered.

Consider adding a companion test case that includes an i.response[].originalRequest.url.query array with a { key: null, value: null } entry and asserts it's excluded from brunoCollection.items[0].examples[0].request.params.

📝 Suggested additional test case
+  it('should skip null query params in originalRequest (example response)', async () => {
+    const collection = {
+      info: {
+        _postman_id: 'test-null-orig-req',
+        name: 'collection',
+        schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json'
+      },
+      item: [
+        {
+          name: 'request',
+          request: {
+            method: 'GET',
+            header: [],
+            url: { raw: 'https://example.com/api' }
+          },
+          response: [
+            {
+              name: 'Example 1',
+              originalRequest: {
+                method: 'GET',
+                url: {
+                  raw: 'https://example.com/api?q=hello',
+                  query: [
+                    { key: 'q', value: 'hello' },
+                    { key: null, value: null },
+                    { key: null, value: 'x' }
+                  ]
+                }
+              },
+              status: 'OK',
+              code: 200,
+              body: ''
+            }
+          ]
+        }
+      ]
+    };
+
+    const brunoCollection = await postmanToBruno(collection);
+    const params = brunoCollection.items[0].examples[0].request.params;
+
+    expect(params).toHaveLength(2);
+    expect(params[0]).toMatchObject({ name: 'q', value: 'hello', type: 'query' });
+    expect(params[1]).toMatchObject({ name: '', value: 'x', type: 'query' });
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js`
around lines 608 - 658, Add a companion test that exercises the
originalRequest.url.query null-filter path by creating a collection object where
an item has a response array whose first element contains
originalRequest.url.query including an entry { key: null, value: null }; call
postmanToBruno and then assert that
brunoCollection.items[0].examples[0].request.params does not include the
fully-null entry (check length) and that the remaining params are normalized the
same way as in the existing test (null key -> '', null value -> ''). This will
cover the code in the originalRequest.url.query.forEach null-guard.
🤖 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-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js`:
- Around line 608-658: Add a companion test that exercises the
originalRequest.url.query null-filter path by creating a collection object where
an item has a response array whose first element contains
originalRequest.url.query including an entry { key: null, value: null }; call
postmanToBruno and then assert that
brunoCollection.items[0].examples[0].request.params does not include the
fully-null entry (check length) and that the remaining params are normalized the
same way as in the existing test (null key -> '', null value -> ''). This will
cover the code in the originalRequest.url.query.forEach null-guard.

value: param.value,
name: param.key ?? '',
value: param.value ?? '',
description: transformDescription(param.description),
Copy link
Member

@abhishek-bruno abhishek-bruno Feb 19, 2026

Choose a reason for hiding this comment

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

Header params are pushed without any null guard. If Postman can produce null keys/values for headers too, the same crash could happen there. Worth investigating.

if (param.key == null && param.value == null) {
return;
}
brunoRequestItem.request.params.push({
Copy link
Member

Choose a reason for hiding this comment

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

Can we consider extracting a shared helper to normalizeQueryParams, since the null-guard + nullish checking logic is duplicated in two places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like it may not be ideal, it is just a simple guard clause right? do you have any specific implementation in mind? Am i missing something here.

Updated the importPostmanV2CollectionItem function to skip headers, URL-encoded parameters, and form data where both key and value are null. Added corresponding test cases to ensure proper handling of these scenarios in the conversion process.
@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 19, 2026
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