Skip to content

fix: correctly parse insomnia exported yaml - #7966

Merged
naman-bruno merged 4 commits into
usebruno:mainfrom
prateek-bruno:bugfix/insomnia-yaml-importer
Jun 18, 2026
Merged

naman-bruno merged 4 commits into
usebruno:mainfrom
prateek-bruno:bugfix/insomnia-yaml-importer

Conversation

@prateek-bruno

@prateek-bruno prateek-bruno commented May 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Jira

Fixes #7687 #6095

Insomnia yaml export didn't had quotes for string so values like: 2024-01-01 were getting parsed as date by our parser.

What this does:

  • Update our file and url import flow to use JSON_SCHEMA, which will preserver 2024-01-01 as String and not Date.
  • Also update normalizeVariables to correctly convert the value to string, so parameters are treated as strings

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

  • Bug Fixes

    • Improved YAML/API spec parsing during imports for more accurate type interpretation
    • Enhanced variable handling so falsy values (0, false) are preserved correctly when importing
    • Improved date type preservation when importing Insomnia collections
  • Tests

    • Added test coverage and fixture to validate date and scalar handling for Insomnia v5 imports

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

YAML parsing in both file and URL import paths now uses jsyaml.JSON_SCHEMA to avoid automatic date coercion; normalizeVariables coerces values with String(value ?? ''); tests and a fixture assert date-like scalars and quoted values are preserved as strings after import.

Changes

Insomnia Date Import Fix

Layer / File(s) Summary
YAML Schema for Safe Parsing
packages/bruno-app/src/components/Sidebar/ImportCollection/FileTab.js, packages/bruno-app/src/utils/importers/common.js
jsyaml.load() now uses jsyaml.JSON_SCHEMA in file-based and API-spec import paths to prevent automatic coercion of date-like strings to Date objects.
Variable Normalization Safety
packages/bruno-converters/src/insomnia/insomnia-to-bruno.js
normalizeVariables now coerces with String(value ?? '') instead of `value
Test Fixture and Verification
tests/import/insomnia/fixtures/insomnia-v5-dates.yaml, tests/import/insomnia/import-insomnia-v5-date-types.spec.ts
Adds an Insomnia v5 fixture and Playwright test that import the fixture and assert date-like scalars (2024-01-01, 2024-12-31) remain unquoted strings while certain quoted numeric/boolean values remain quoted.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • usebruno/bruno#7063: Modifies FileTab.convertFileToObject and import parsing logic, related to the YAML schema changes here.

Suggested labels

size/M

Suggested reviewers

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

Poem

Dates kept as strings, no covert shift,
Parsers chosen to guard the drift,
Values coerced before the match,
Tests confirm nothing will detach,
Import safely sails—codecraft gift.

🚥 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 identifies the main fix: correcting YAML parsing for Insomnia exports, which aligns with the core changes across multiple files.
Linked Issues check ✅ Passed The PR fully addresses #7687 by using JSON_SCHEMA for YAML parsing and implementing defensive string conversion in normalizeVariables, preventing type coercion errors.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing Insomnia YAML parsing: schema updates in two import paths and defensive conversion in the normalizeVariables function.
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.

@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 (1)
tests/import/insomnia/import-insomnia-v5-date-types.spec.ts (1)

11-34: ⚡ Quick win

Consider adding test.step for better reporting.

The test correctly validates the date preservation fix, but would benefit from using test.step to break down the logical phases (import → read file → verify) for clearer test reports.

📊 Suggested structure with test.step
  test('should keep date-like strings and quoted values intact through the full FileTab.js import flow', async ({
    page,
    createTmpDir
  }) => {
-   const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml');
-   const collectionName = 'Date Type Test';
-   const collectionDir = await createTmpDir('insomnia-dates-test');
-
-   await importCollection(page, insomniaFile, collectionDir, {
-     expectedCollectionName: collectionName
-   });
-
-   const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml');
-   const yamlContent = fs.readFileSync(requestFilePath, 'utf8');
-
-   expect(yamlContent).toContain('value: 2024-01-01');
-   expect(yamlContent).not.toContain('Mon Jan');
-   expect(yamlContent).not.toContain('GMT');
-
-   expect(yamlContent).toMatch(/value:\s*"false"/);
-   expect(yamlContent).toMatch(/value:\s*"0"/);
-   expect(yamlContent).toMatch(/value:\s*"2\.0"/);
-   expect(yamlContent).toContain('value: "42"');
+   await test.step('Import Insomnia v5 collection with date-like values', async () => {
+     const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml');
+     const collectionName = 'Date Type Test';
+     const collectionDir = await createTmpDir('insomnia-dates-test');
+
+     await importCollection(page, insomniaFile, collectionDir, {
+       expectedCollectionName: collectionName
+     });
+   });
+
+   await test.step('Verify date-like strings are preserved as strings', async () => {
+     const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml');
+     const yamlContent = fs.readFileSync(requestFilePath, 'utf8');
+
+     expect(yamlContent).toContain('value: 2024-01-01');
+     expect(yamlContent).not.toContain('Mon Jan');
+     expect(yamlContent).not.toContain('GMT');
+   });
+
+   await test.step('Verify quoted scalar values are preserved', async () => {
+     const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml');
+     const yamlContent = fs.readFileSync(requestFilePath, 'utf8');
+
+     expect(yamlContent).toMatch(/value:\s*"false"/);
+     expect(yamlContent).toMatch(/value:\s*"0"/);
+     expect(yamlContent).toMatch(/value:\s*"2\.0"/);
+     expect(yamlContent).toContain('value: "42"');
+   });
  });

Note: You'll need to make collectionDir and collectionName available across steps, either by declaring them outside or restructuring slightly.

Based on coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read."

🤖 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/insomnia/import-insomnia-v5-date-types.spec.ts` around lines 11
- 34, Split the test 'should keep date-like strings and quoted values intact
through the full FileTab.js import flow' into clear steps using test.step: wrap
the importCollection call in a test.step labeled "import collection", the
fs.readFileSync call that loads requestFilePath in "read exported file", and the
expect assertions in "verify values"; to make this work declare collectionDir
and collectionName in the outer test scope (before the steps) so they are shared
across steps and leave function calls/imports (importCollection, path.join,
fs.readFileSync) unchanged.
🤖 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.

Nitpick comments:
In `@tests/import/insomnia/import-insomnia-v5-date-types.spec.ts`:
- Around line 11-34: Split the test 'should keep date-like strings and quoted
values intact through the full FileTab.js import flow' into clear steps using
test.step: wrap the importCollection call in a test.step labeled "import
collection", the fs.readFileSync call that loads requestFilePath in "read
exported file", and the expect assertions in "verify values"; to make this work
declare collectionDir and collectionName in the outer test scope (before the
steps) so they are shared across steps and leave function calls/imports
(importCollection, path.join, fs.readFileSync) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 784e57a1-6ee8-4686-9b69-ebae80dcce6f

📥 Commits

Reviewing files that changed from the base of the PR and between 0c7bce3 and a9c7ae9.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/Sidebar/ImportCollection/FileTab.js
  • packages/bruno-app/src/utils/importers/common.js
  • packages/bruno-converters/src/insomnia/insomnia-to-bruno.js
  • tests/import/insomnia/fixtures/insomnia-v5-dates.yaml
  • tests/import/insomnia/import-insomnia-v5-date-types.spec.ts

@pull-request-size pull-request-size Bot added size/L and removed size/M labels May 26, 2026

@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 (1)
tests/import/insomnia/import-insomnia-v5-date-types.spec.ts (1)

11-55: ⚡ Quick win

Consider wrapping logical test sections in test.step for improved reporting.

The test has three distinct phases (import, verify request, verify environment) that would benefit from test.step blocks. This makes test reports easier to understand when failures occur. As per coding guidelines, Playwright tests should promote the use of test.step as much as possible.

📊 Suggested refactor with test.step blocks
   test('should keep date-like strings and quoted values intact through the full FileTab.js import flow', async ({
     page,
     createTmpDir
   }) => {
-    const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml');
-    const collectionName = 'Date Type Test';
-    const collectionDir = await createTmpDir('insomnia-dates-test');
-
-    await importCollection(page, insomniaFile, collectionDir, {
-      expectedCollectionName: collectionName
-    });
-
-    const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml');
-    const yamlContent = fs.readFileSync(requestFilePath, 'utf8');
-
-    expect(yamlContent).toContain(`  params:
+    await test.step('Import collection from fixture', async () => {
+      const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml');
+      const collectionName = 'Date Type Test';
+      const collectionDir = await createTmpDir('insomnia-dates-test');
+
+      await importCollection(page, insomniaFile, collectionDir, {
+        expectedCollectionName: collectionName
+      });
+    });
+
+    await test.step('Verify request params preserve date-like and quoted values', async () => {
+      const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml');
+      const yamlContent = fs.readFileSync(requestFilePath, 'utf8');
+
+      expect(yamlContent).toContain(`  params:
     - name: date
       value: 2024-01-01
       type: query
@@ -38,18 +46,21 @@
     - name: count
       value: "42"
       type: query
 `);
+    });
 
-    const envFilePath = path.join(collectionDir, collectionName, 'environments', 'Base.yml');
-    const envContent = fs.readFileSync(envFilePath, 'utf8');
-
-    expect(envContent).toContain(`variables:
+    await test.step('Verify environment variables preserve date-like and quoted values', async () => {
+      const envFilePath = path.join(collectionDir, collectionName, 'environments', 'Base.yml');
+      const envContent = fs.readFileSync(envFilePath, 'utf8');
+
+      expect(envContent).toContain(`variables:
   - name: expiry_date
     value: 2024-12-31
   - name: max_retries
     value: "3"
   - name: enabled
     value: "true"
 `);
+    });
   });

Note: You'll need to move the variable declarations (insomniaFile, collectionName, collectionDir) outside the first step so they're accessible in subsequent steps.

🤖 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/insomnia/import-insomnia-v5-date-types.spec.ts` around lines 11
- 55, Split the test 'should keep date-like strings and quoted values intact
through the full FileTab.js import flow' into explicit Playwright steps by
wrapping the three logical phases (import, verify request file, verify
environment file) in test.step blocks; move shared variables (insomniaFile,
collectionName, collectionDir) out of the first step so they are declared before
the steps and accessible to all, then wrap the call to importCollection(page,
insomniaFile, collectionDir, { expectedCollectionName: collectionName }) in the
first test.step and put the two expect blocks that read
requestFilePath/yamlContent and envFilePath/envContent each in their own
test.step for clearer reporting.
🤖 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.

Nitpick comments:
In `@tests/import/insomnia/import-insomnia-v5-date-types.spec.ts`:
- Around line 11-55: Split the test 'should keep date-like strings and quoted
values intact through the full FileTab.js import flow' into explicit Playwright
steps by wrapping the three logical phases (import, verify request file, verify
environment file) in test.step blocks; move shared variables (insomniaFile,
collectionName, collectionDir) out of the first step so they are declared before
the steps and accessible to all, then wrap the call to importCollection(page,
insomniaFile, collectionDir, { expectedCollectionName: collectionName }) in the
first test.step and put the two expect blocks that read
requestFilePath/yamlContent and envFilePath/envContent each in their own
test.step for clearer reporting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b3cf838c-3e99-47e3-8c19-aa61f073341f

📥 Commits

Reviewing files that changed from the base of the PR and between a9c7ae9 and 396b1d2.

📒 Files selected for processing (1)
  • tests/import/insomnia/import-insomnia-v5-date-types.spec.ts

@utkarsh-bruno utkarsh-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The changes make sense. Looks good to me.

@naman-bruno
naman-bruno merged commit 36e59e9 into usebruno:main Jun 18, 2026
19 of 20 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.

Insomnia converter does not serialize values cleanly

4 participants