Skip to content

fix: curl import with --data-binary and json content-type crashes#7880

Open
desperadoxhy wants to merge 1 commit intousebruno:mainfrom
desperadoxhy:fix/curl-data-binary-import
Open

fix: curl import with --data-binary and json content-type crashes#7880
desperadoxhy wants to merge 1 commit intousebruno:mainfrom
desperadoxhy:fix/curl-data-binary-import

Conversation

@desperadoxhy
Copy link
Copy Markdown

@desperadoxhy desperadoxhy commented Apr 29, 2026

Summary

  • Fix crash (e.file?.map is not a function) when importing a curl command that uses --data-binary with application/json content-type
  • The parser was incorrectly treating --data-binary as a file upload before checking content-type, causing the Redux store to call .map() on a string value

Problem

When importing this curl command:

curl 'https://example.com/api' \
  -H 'content-type: application/json' \
  --data-binary '{"data":{"status":12}}'

The --data-binary flag caused the parser to set body.mode = 'file' and body.file = parsedBody (a JSON string), skipping the content-type check entirely. The Redux store then crashed because it expected body.file to be an array.

Fix

Removed the premature request.isDataBinary check so that content-type-based detection (application/json → json mode, etc.) takes priority. The --data-binary flag in curl controls data transmission behavior, not the body type.

Test plan

  • Import curl command with --data-binary + application/json content-type → correctly parsed as JSON body
  • Import curl command with --data-binary + application/xml content-type → correctly parsed as XML body
  • Import regular curl commands without --data-binary → unaffected

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed handling of binary data when importing curl commands. Binary data now processes based on content-type instead of being treated as a file upload.

When importing a curl command that uses `--data-binary` with
`application/json` content-type, the parser incorrectly treated it as a
file upload (body.mode = 'file') before checking the content-type.
This caused `e.file?.map is not a function` because the Redux store
expects body.file to be an array.

The `--data-binary` flag in curl controls data transmission, not body
type. Remove the premature isDataBinary check so content-type-based
detection (json, xml, form, etc.) takes priority.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 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: 765e075f-9a96-44a4-a3e9-4648597a19e0

📥 Commits

Reviewing files that changed from the base of the PR and between ff6ec4a and f05b745.

📒 Files selected for processing (1)
  • packages/bruno-app/src/utils/curl/index.js
💤 Files with no reviewable changes (1)
  • packages/bruno-app/src/utils/curl/index.js

Walkthrough

The getRequestFromCurlCommand function in the curl import utility removes special handling for request.isDataBinary. Binary data now flows through standard content-type-based logic instead of being treated as file uploads, eliminating the body.mode = 'file' assignment path.

Changes

Cohort / File(s) Summary
cURL Import Logic
packages/bruno-app/src/utils/curl/index.js
Removes special-case handling for binary data that forced file-mode interpretation; binary payloads now defer to content-type routing (JSON, XML, form, multipart, etc.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • PR #7210: Modifies curl import to treat only @file references as file uploads rather than all --data-binary arguments—directly related control-flow change.
  • PR #7002: Extends cURL request-body handling with NDJSON detection; complements this PR by expanding content-type routing that binary data now uses.

Suggested labels

size/S

Suggested reviewers

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

Poem

💨 Binary data takes the scenic route,
No forced files, just content-type boots,
Flow through JSON, XML, form divine,
Simpler paths make everything align. ✨

🚥 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 and specifically describes the main fix: resolving a crash when importing curl commands with --data-binary and JSON content-type.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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.

1 participant