Skip to content

fix(bruno-converters): serialize Postman GraphQL variables to JSON st… - #9635

Open
sahilshingate01 wants to merge 1 commit into
usebruno:mainfrom
sahilshingate01:bugfix/postman-graphql-variables-serialization
Open

sahilshingate01 wants to merge 1 commit into
usebruno:mainfrom
sahilshingate01:bugfix/postman-graphql-variables-serialization

Conversation

@sahilshingate01

@sahilshingate01 sahilshingate01 commented Oct 24, 2026 •

Copy link
Copy Markdown

Description

Fixes a runtime crash when executing GraphQL requests imported from Postman collections by ensuring GraphQL variables are stringified, and safely guards parseGraphQLRequest against null-prototype sources.

Problem

  1. When importing a Postman collection containing a GraphQL request where variables are stored as an object (standard Postman v2.1 format), parseGraphQLRequest directly assigned the object to brunoRequestItem.request.body.graphql.variables. During execution, prepare-request.js passes variables to decomment(vars || '{}'), which throws TypeError: Input must be a string, crashing the runner.
  2. parseGraphQLRequest called graphqlSource.hasOwnProperty(...) directly. If graphqlSource lacked Object.prototype (e.g. Object.create(null)), an uncaught TypeError was thrown, losing query and variable data.

Fix

  1. Updated parseGraphQLRequest in packages/bruno-converters/src/postman/postman-to-bruno.js to serialize object variables to formatted JSON strings (JSON.stringify(..., null, 2)).
  2. Used Object.prototype.hasOwnProperty.call(graphqlSource, ...) for both variables and query.
  3. Added unit tests in packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js validating conversion of object variables, string variables, null variables, and null-prototype sources.

Summary by CodeRabbit

  • Bug Fixes
    • Improved importing GraphQL requests from Postman when query or variables are missing, null, or provided in different formats.
    • Object variables are formatted as JSON, while string variables are preserved. Non-string query values are converted to text, and invalid GraphQL data results in empty query and variables.
    • GraphQL imports are recognized correctly when the source data uses a null-prototype object.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ab6e3ef and c986556.

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

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The Postman-to-Bruno converter now normalizes GraphQL query and variable values based on their types. Tests cover object, string, and null values, plus a null-prototype source object.

Changes

GraphQL import

Layer / File(s) Summary
Normalize GraphQL values and verify imports
packages/bruno-converters/src/postman/postman-to-bruno.js, packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js
The parser returns empty values for falsy input, skips null and empty-string fields, serializes object variables as JSON, and converts other non-string values to strings. Tests cover these cases and null-prototype input.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • usebruno/bruno#9602: Both changes address GraphQL variable handling. This converter prepares values consumed by the downstream comment-stripping step.

Suggested labels: size/L

Suggested reviewers: sanish-bruno, lohit-bruno

Merge Risk: Minimal · up to c9865

No actionable issue is identified for the GraphQL import change; it is mergeable after normal checks.

Pre-merge checks: Passed 5
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 change: serializing Postman GraphQL variables to JSON strings. It is concise and directly related to the pull request.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Queries meet their string-shaped form
Object variables take JSON form
Null fields leave an empty space
Tests check each imported case
GraphQL finds a steady path

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

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

1 participant