Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hurlfmt: Illegal headers from curl input cause panic #3668

Open
theoforger opened this issue Jan 29, 2025 · 0 comments
Open

hurlfmt: Illegal headers from curl input cause panic #3668

theoforger opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@theoforger
Copy link
Contributor

What is the current bug behavior?

When using hurlfmt with the option --in curl, if the input file contains any illegal headers, the program would simply panic.

hurlfmt, when executed with --in curl, does not check the validity of headers before converting curl commands into the hurl file format. Illegal headers can make their way into the hurl file, and then cause issues with the parser hurl_core::parser::parse_hurl_file.

It's also worth mentioning that, with curl, illegal headers don't seem to result in a crash, nor does curl display any error messages. It simply ignores the header.

Steps to reproduce

  1. Prepare a file with a curl command which contains an illegal header. For example:
# example.curl:
curl --header 'illegal-header' 'https://httpbin.org/status/200'
  1. Use this file as an input for hurlfmt:
$ hurlfmt --in curl example.curl
  1. Panic:
thread 'main' panicked at packages/hurl_core/src/error/mod.rs:228:38:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Possible fixes

  1. Add a safeguard in hurlfmt to check curl headers before conversion.
  2. Handle this error in the parser. Display a proper error message if the header is illegal.
@theoforger theoforger added the bug Something isn't working label Jan 29, 2025
@jcamiel jcamiel added this to the 6.1.0 milestone Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants