Skip to content

feat: add helper to ensure string conversion for non-string values in Postman to Bruno conversion - #7644

Merged
bijin-bruno merged 3 commits into
usebruno:mainfrom
sanish-bruno:fix/number-params-headers
Apr 1, 2026
Merged

bijin-bruno merged 3 commits into
usebruno:mainfrom
sanish-bruno:fix/number-params-headers

Conversation

@sanish-bruno

@sanish-bruno sanish-bruno commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator

Jira

  • Introduced ensureString function to convert numeric and non-string values to strings, defaulting null/undefined to an empty string.
  • Updated request handling in importPostmanV2CollectionItem to utilize ensureString for headers, parameters, and body fields.
  • Added tests to verify correct conversion of numeric values to strings in headers, query parameters, and body fields.

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

    • Postman → Bruno import now consistently converts all non-string field values (headers, URL/query/path parameters, multipart and url-encoded form fields, and example bodies/responses) to strings for more reliable imports.
  • Tests

    • Added tests that verify numeric and other non-string values in requests and examples are coerced to string form during conversion.

… Postman to Bruno conversion

- Introduced `ensureString` function to convert numeric and non-string values to strings, defaulting null/undefined to an empty string.
- Updated request handling in `importPostmanV2CollectionItem` to utilize `ensureString` for headers, parameters, and body fields.
- Added tests to verify correct conversion of numeric values to strings in headers, query parameters, and body fields.
@coderabbitai

coderabbitai Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f34f59ec-4403-4d5b-9499-1f524921e944

📥 Commits

Reviewing files that changed from the base of the PR and between e0e4426 and ec9cf90.

📒 Files selected for processing (1)
  • packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js
✅ Files skipped from review due to trivial changes (1)
  • packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js

Walkthrough

Added an ensureString helper to normalize Postman field values into Bruno-compatible strings and applied it across headers, URL params, multipart/form and formUrlEncoded entries and example conversions; added tests asserting numeric values are coerced to strings.

Changes

Cohort / File(s) Summary
Converter - string normalization
packages/bruno-converters/src/postman/postman-to-bruno.js
Add ensureString() and replace ad-hoc ?? '' / String(...) conversions with ensureString for headers, URL params (query/path), multipart/form-data and formUrlEncoded entries, and example request/response mappings.
Tests - numeric coercion
packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js
Add Jest tests that verify numeric values in headers, query params, path variables, urlencoded and multipart/form fields (including example responses) are converted to strings in the Bruno output.

Sequence Diagram(s)

(omitted — changes are limited to normalization helper and tests; no new multi-component control flow requiring sequence diagrams)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

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

Poem

A helper small, with quiet might,
Numbers fold to strings at night,
Headers, forms, and params align—
Conversion whispers, all is fine ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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: introducing an ensureString helper to normalize non-string values during Postman to Bruno conversion, which is the core purpose of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

…formation

- Implemented a new test case to verify that numeric values in example request and response fields are correctly converted to strings during the Postman to Bruno conversion process.
- The test checks various components including request headers, query parameters, path parameters, and body fields to ensure proper string conversion.

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

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

818-818: Nit: Missing newline before the new test.

There's no blank line separating the previous test's closing brace from the new test. The surrounding tests have consistent blank line separation.

Suggested fix
   });
+
   it('should convert numeric values to strings in headers, params, and body fields', async () => {
🤖 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`
at line 818, Add a single blank line separating the previous test's closing
brace and the new test declaration so tests match the surrounding style; insert
a newline between the prior test's closing "}" and the next "test(...)"/
"it(...)" block to maintain consistent blank-line separation.
packages/bruno-converters/src/postman/postman-to-bruno.js (1)

171-180: Consider using ensureString here for consistency.

The inline logic at line 175 duplicates the null/string/object handling that ensureString now provides. You could simplify:

-    value: v.value == null ? '' : typeof v.value === 'string' ? v.value : JSON.stringify(v.value),
+    value: ensureString(v.value),

This would unify all value normalization under a single helper.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-converters/src/postman/postman-to-bruno.js` around lines 171 -
180, The mapping in importCollectionLevelVariables currently normalizes variable
values inline (the ternary at the value property) and duplicates logic; replace
that inline normalization with a call to the existing ensureString helper (use
ensureString(v.value)) so all value conversion (null/object/string) is
centralized; update the value assignment in the vars mapping inside
importCollectionLevelVariables to use ensureString and keep uid, name, enabled
logic the same.
🤖 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/src/postman/postman-to-bruno.js`:
- Around line 171-180: The mapping in importCollectionLevelVariables currently
normalizes variable values inline (the ternary at the value property) and
duplicates logic; replace that inline normalization with a call to the existing
ensureString helper (use ensureString(v.value)) so all value conversion
(null/object/string) is centralized; update the value assignment in the vars
mapping inside importCollectionLevelVariables to use ensureString and keep uid,
name, enabled logic the same.

In
`@packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js`:
- Line 818: Add a single blank line separating the previous test's closing brace
and the new test declaration so tests match the surrounding style; insert a
newline between the prior test's closing "}" and the next "test(...)"/ "it(...)"
block to maintain consistent blank-line separation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de22eec7-9ccb-40ea-96b8-5a5eae4ed1ca

📥 Commits

Reviewing files that changed from the base of the PR and between aa7b8f4 and 9dad832.

📒 Files selected for processing (2)
  • packages/bruno-converters/src/postman/postman-to-bruno.js
  • packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js

… to Bruno transformation

- Added a new test case to verify that numeric values in multipart form data are correctly converted to strings during the Postman to Bruno conversion process.
- The test checks the conversion of numeric values in the request body to ensure proper handling in the transformation.
@bijin-bruno
bijin-bruno merged commit c502f95 into usebruno:main Apr 1, 2026
10 checks passed
lohit-bruno pushed a commit that referenced this pull request Apr 3, 2026
… Postman to Bruno conversion (#7644)

* feat: add helper to ensure string conversion for non-string values in Postman to Bruno conversion

- Introduced `ensureString` function to convert numeric and non-string values to strings, defaulting null/undefined to an empty string.
- Updated request handling in `importPostmanV2CollectionItem` to utilize `ensureString` for headers, parameters, and body fields.
- Added tests to verify correct conversion of numeric values to strings in headers, query parameters, and body fields.

* test: add test for numeric value conversion in Postman to Bruno transformation

- Implemented a new test case to verify that numeric values in example request and response fields are correctly converted to strings during the Postman to Bruno conversion process.
- The test checks various components including request headers, query parameters, path parameters, and body fields to ensure proper string conversion.

* test: add multipart form value test for numeric conversion in Postman to Bruno transformation

- Added a new test case to verify that numeric values in multipart form data are correctly converted to strings during the Postman to Bruno conversion process.
- The test checks the conversion of numeric values in the request body to ensure proper handling in the transformation.
maxenceleblanc pushed a commit to maxenceleblanc/curly_cats2 that referenced this pull request Jul 20, 2026
… Postman to Bruno conversion (usebruno#7644)

* feat: add helper to ensure string conversion for non-string values in Postman to Bruno conversion

- Introduced `ensureString` function to convert numeric and non-string values to strings, defaulting null/undefined to an empty string.
- Updated request handling in `importPostmanV2CollectionItem` to utilize `ensureString` for headers, parameters, and body fields.
- Added tests to verify correct conversion of numeric values to strings in headers, query parameters, and body fields.

* test: add test for numeric value conversion in Postman to Bruno transformation

- Implemented a new test case to verify that numeric values in example request and response fields are correctly converted to strings during the Postman to Bruno conversion process.
- The test checks various components including request headers, query parameters, path parameters, and body fields to ensure proper string conversion.

* test: add multipart form value test for numeric conversion in Postman to Bruno transformation

- Added a new test case to verify that numeric values in multipart form data are correctly converted to strings during the Postman to Bruno conversion process.
- The test checks the conversion of numeric values in the request body to ensure proper handling in the transformation.
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.

3 participants