Skip to content

fix(converters): ensure insomnia variables are strings before matching#7714

Open
jayesh70599 wants to merge 1 commit intousebruno:mainfrom
jayesh70599:bugfix/insomnia-import-type-error
Open

fix(converters): ensure insomnia variables are strings before matching#7714
jayesh70599 wants to merge 1 commit intousebruno:mainfrom
jayesh70599:bugfix/insomnia-import-type-error

Conversation

@jayesh70599
Copy link
Copy Markdown

@jayesh70599 jayesh70599 commented Apr 8, 2026

Description

Fixes #7687

The Problem

When importing Insomnia collections in YAML format, unquoted values (such as dates, numbers, or booleans) are parsed as non-string JavaScript types. Because the normalizeVariables function immediately calls .match() on these values, it triggers a TypeError: value.match is not a function, causing the entire import process to crash.

The Fix

I have updated the normalizeVariables function in packages/bruno-converters/src/insomnia/insomnia-to-bruno.js to explicitly cast incoming values to a String.

  • Used a nullish check (value != null) to ensure that null or undefined default to an empty string.
  • Guaranteed that values like 0 (number) or false (boolean) are correctly converted to "0" and "false" rather than being treated as falsy and erased.

Verification

  • Created a reproduction Insomnia YAML export containing unquoted integers and dates.
  • Verified that the import fails with a TypeError in the console before the fix.
  • Verified that the import succeeds and correctly populates headers and variables after the fix.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed variable normalization during Insomnia to Bruno conversion to properly preserve falsy values such as 0 and false, instead of converting them to empty strings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

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: 08bf15e9-2663-4bf7-9c84-480aaeb6b52a

📥 Commits

Reviewing files that changed from the base of the PR and between 3b502fd and 4e0dffd.

📒 Files selected for processing (1)
  • packages/bruno-converters/src/insomnia/insomnia-to-bruno.js

Walkthrough

The normalizeVariables function in the Insomnia converter was modified to explicitly convert non-string values to strings using null coalescing (value != null ? String(value) : '') instead of relying on the OR operator, preserving falsy values during variable normalization.

Changes

Cohort / File(s) Summary
Variable Normalization
packages/bruno-converters/src/insomnia/insomnia-to-bruno.js
Updated normalizeVariables to use null coalescing with String conversion instead of OR operator, ensuring falsy non-string values (e.g., 0, false, dates) are preserved and stringified rather than replaced with empty strings.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • PR #7476: Similar variable normalization fix in Postman converter to preserve non-string values during import.

Suggested labels

size/S

Suggested reviewers

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

Poem

🔢 Zero and false shall now survive,
No more casting them aside alive,
String() embraces all that's real,
A cleaner normalize—what a deal! ✨

🚥 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 accurately describes the main change: converting Insomnia variables to strings before calling .match() to prevent TypeErrors.
Linked Issues check ✅ Passed The PR directly implements the requested fix from #7687 by replacing value || '' with value != null ? String(value) : '' to handle non-string JS types from YAML parsing.
Out of Scope Changes check ✅ Passed Only the normalizeVariables function in the specified file was modified; no extraneous changes are present.
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.

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.

Insomnia converter does not serialize values cleanly

1 participant