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

thread 'main' panicked at 'explicit panic', packages/hurl/src/runner/predicate.rs:242:9 #514

Closed
humphd opened this issue Mar 21, 2022 · 3 comments · Fixed by #518
Closed
Labels
bug Something isn't working
Milestone

Comments

@humphd
Copy link

humphd commented Mar 21, 2022

Given:

POST http://localhost:8080/v1/fragments
Authorization: Basic dXNlcjFAZW1haWwuY29tOnBhc3N3b3JkMQ==
Content-Type: text/plain
```This is a fragment!```

HTTP/1.1 201
[Asserts]
header "Location" matches /^http:\/\/localhost:8080\/v1\/fragments\/[A-Za-z0-9_-]+$/

Produces:

tests/integration/post-fragments.hurl: RUNNING [1/1]
thread 'main' panicked at 'explicit panic', packages/hurl/src/runner/predicate.rs:242:9
stack backtrace:
   0:        0x102a4e83c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3ed8329ca233c030
   1:        0x102a685c0 - core::fmt::write::hbd9d12683bef04dd
   2:        0x102a3e0ac - std::io::Write::write_fmt::hcac916a8f5a89cd1
   3:        0x102a430e4 - std::panicking::default_hook::{{closure}}::h2a7f31dca627b9fc
   4:        0x102a42d5c - std::panicking::default_hook::h3b6723f5e498edb5
   5:        0x102a43628 - std::panicking::rust_panic_with_hook::hbaa3c19666ce2f90
   6:        0x10285f518 - std::panicking::begin_panic::{{closure}}::h98efcfcf76d06f11
   7:        0x10285f16c - std::sys_common::backtrace::__rust_end_short_backtrace::h562d10abf4986bfb
   8:        0x102a76848 - std::panicking::begin_panic::hd55f7ace4dca44bc
   9:        0x102888024 - hurl::runner::predicate::eval_predicate::h33a6fee8beacc851
  10:        0x102868d1c - hurl::runner::assert::eval_assert::h6a795519153be709
  11:        0x1028948e0 - hurl::runner::response::eval_asserts::h7b75032d76e4646c
  12:        0x10283c79c - hurl::runner::entry::run::h399ca78d956be712
  13:        0x1028437bc - hurl::runner::hurl_file::run::hee964bc2019416b1
  14:        0x10281bf48 - hurl::main::h1ea3276939170626
  15:        0x102840100 - std::sys_common::backtrace::__rust_begin_short_backtrace::h57a5d0a77ac6eb4f
  16:        0x102822e40 - std::rt::lang_start::{{closure}}::h3868ec1f5bf288a1
  17:        0x102a38f1c - std::rt::lang_start_internal::h7776a329c9bee45b
  18:        0x1028202b8 - _main
@humphd
Copy link
Author

humphd commented Mar 21, 2022

Switching the regex to use "..." vs. /.../ stops the crash

@jcamiel
Copy link
Collaborator

jcamiel commented Mar 22, 2022

Hi @humphd this is definitively a bug: it happens in case of a regex predicate value (like yours /^http:\/\/localhost:8080\/v1\/fragments\/[A-Za-z0-9_-]+$/) when the asserts is failling. When we try to print the error description, we erroneously panic in case of regex. If the assert is successful, the test is passing so definitively a bad bug.

We're going to produce a 1.6.1 patch version for the end of the week (as this bug can be triggered easily with also the fix for the @ in BasicAuth section).

As a side node (not at all related to this bug), in your sample:

POST http://localhost:8080/v1/fragments
Authorization: Basic dXNlcjFAZW1haWwuY29tOnBhc3N3b3JkMQ==
Content-Type: text/plain
```This is a fragment!```

You are using what we call a "raw string" (```This is a fragment!```).
In a future version, we would like to add "format" hints to this syntax. For instance:

  • base64 multiline:
POST sample.com
```base64
FkaXBpc2NpbmcgZWxpdC4gSW4gbWFsZXN1YWRhLCBuaXNsIHZlbCBkaWN0dW0g
aGVuZHJlcml0LCBlc3QganVzdG8gYmliZW5kdW0gbWV0dXMsIG5lYyBydXRydW
```
  • GraphQL multiline:
POST sample.com
```graphql
{
  human(id: "1000") {
    name
    height(unit: FOOT)
  }
}
```
  • Binary multiline:
POST sample.com
```hex
47455420687474703a2f2f6c6f63616c
686f73743a383030300a417574686f72
697a6174696f6e3a2042617369632064
584e6c636a46415a5731686157777559
3239744f6e426863334e3362334a6b4d
```
  • Basic text:
POST http://localhost:8080/v1/fragments
```
This is a fragment!
```

This will allow us to specify a certain type of body (like a GraphQL request) that will be transformed to a real HTTP request body (and maybe with adding an appropriate Content-Type). To simplify the parser, we would like to deprecate the syntax on one line. For instance:

POST http://localhost:8080/v1/fragments
Authorization: Basic dXNlcjFAZW1haWwuY29tOnBhc3N3b3JkMQ==
Content-Type: text/plain
```This is a fragment!```

Will not longer be accepted and should be rewritten as:

POST http://localhost:8080/v1/fragments
Authorization: Basic dXNlcjFAZW1haWwuY29tOnBhc3N3b3JkMQ==
Content-Type: text/plain
```
This is a fragment!
```

JSON body and xml body can still be used without ```of course.

Does it seems problematic to you ? I wonder if you're currently using this "one-line" syntax a lot?

@jcamiel jcamiel modified the milestone: 1.6.0 Mar 22, 2022
@jcamiel jcamiel added the bug Something isn't working label Mar 22, 2022
@jcamiel jcamiel added this to the 1.6.1 milestone Mar 22, 2022
@humphd
Copy link
Author

humphd commented Mar 22, 2022

Thanks for fixing so quickly.

I think following the style of GitHub Markdown's fenced code blocks, to indicate content type, is a great idea. The only reason I've used ```...``` in the past was to deal with comparisons in tests where the presence or absence of a newline was significant. In some of my test cases, this matters, so it would be good if there was a way to not always assume/include one, even though I agree that the majority of cases would benefit from an implicit inclusion.

@jcamiel jcamiel linked a pull request Mar 25, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants