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 producing repeated content #2533

Closed
CodeMan99 opened this issue Mar 16, 2024 · 5 comments · Fixed by #2545
Closed

hurlfmt producing repeated content #2533

CodeMan99 opened this issue Mar 16, 2024 · 5 comments · Fixed by #2545
Labels
bug Something isn't working
Milestone

Comments

@CodeMan99
Copy link

What is the current bug behavior? 🪲

When using hurlfmt sometimes a variable placeholder is repeated in the output.

Applies only to --out hurl formatting. Using --out json or --out html do not produce the incorrect behavior.

Steps to reproduce 🔗

Source file, called get_hurl.hurl:

GET https://github.com/Orange-OpenSource/hurl/releases/latest
Accept: application/json
[Options]
location: true
HTTP 200
[Captures]
version: jsonpath "$.tag_name"


GET https://github.com/Orange-OpenSource/hurl/releases/download/{{version}}/hurl_{{version}}_amd64.deb
[Options]
location: true
output: ./hurl_{{version}}_amd64.deb

I then called cargo run --package hurlfmt get_hurl.hurl, which produced:

vscode ➜ /workspaces/hurl (master) $ cargo run --package hurlfmt get_hurl.hurl 
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/hurlfmt get_hurl.hurl`
GET https://github.com/Orange-OpenSource/hurl/releases/latest
Accept: application/json
[Options]
location: true
HTTP 200
[Captures]
version: jsonpath "$.tag_name"


GET https://github.com/Orange-OpenSource/hurl/releases/download/{{version}}/hurl_{{version}}_amd64.deb
[Options]
location: true
output: ./hurl_{{version}}./hurl_{{version}}_amd64.deb

Noticed the last output line where ./hurl_{{version}} is stated twice.

What is the expected correct behavior? ✔️

The input file seems to be mostly formatted correctly. I would only expect colors to be applied. That said, I'm new here! 👋

Execution context 🖥️

  • Hurl Version (hurlfmt --version): hurlfmt 4.3.0-SNAPSHOT @ 0931c32
vscode ➜ /workspaces/hurl (master) $ git log -1 --oneline
0931c3251095 (HEAD -> master, origin/master, origin/HEAD) Add experimental parallel flag.
vscode ➜ /workspaces/hurl (master) $ uname -a
Linux 1443c8565104 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 GNU/Linux
vscode ➜ /workspaces/hurl (master) $ devcontainer-info 

Development container image information

- Image version: 1.0.9
- Definition ID: rust
- Variant: bookworm
- Source code repository: https://github.com/devcontainers/images
- Source code release/branch: v0.3.32
- Timestamp: Tue, 05 Mar 2024 18:10:09 GMT

More info: https://github.com/devcontainers/images/tree/main/src/rust/history/1.0.9.md

Possible fixes

@CodeMan99 CodeMan99 added the bug Something isn't working label Mar 16, 2024
@CodeMan99
Copy link
Author

In case I did something strange while creating my input file, here's a binary dump:

$ xxd get_hurl.hurl
00000000: 4745 5420 6874 7470 733a 2f2f 6769 7468  GET https://gith
00000010: 7562 2e63 6f6d 2f4f 7261 6e67 652d 4f70  ub.com/Orange-Op
00000020: 656e 536f 7572 6365 2f68 7572 6c2f 7265  enSource/hurl/re
00000030: 6c65 6173 6573 2f6c 6174 6573 740a 4163  leases/latest.Ac
00000040: 6365 7074 3a20 6170 706c 6963 6174 696f  cept: applicatio
00000050: 6e2f 6a73 6f6e 0a5b 4f70 7469 6f6e 735d  n/json.[Options]
00000060: 0a6c 6f63 6174 696f 6e3a 2074 7275 650a  .location: true.
00000070: 4854 5450 2032 3030 0a5b 4361 7074 7572  HTTP 200.[Captur
00000080: 6573 5d0a 7665 7273 696f 6e3a 206a 736f  es].version: jso
00000090: 6e70 6174 6820 2224 2e74 6167 5f6e 616d  npath "$.tag_nam
000000a0: 6522 0a0a 0a47 4554 2068 7474 7073 3a2f  e"...GET https:/
000000b0: 2f67 6974 6875 622e 636f 6d2f 4f72 616e  /github.com/Oran
000000c0: 6765 2d4f 7065 6e53 6f75 7263 652f 6875  ge-OpenSource/hu
000000d0: 726c 2f72 656c 6561 7365 732f 646f 776e  rl/releases/down
000000e0: 6c6f 6164 2f7b 7b76 6572 7369 6f6e 7d7d  load/{{version}}
000000f0: 2f68 7572 6c5f 7b7b 7665 7273 696f 6e7d  /hurl_{{version}
00000100: 7d5f 616d 6436 342e 6465 620a 5b4f 7074  }_amd64.deb.[Opt
00000110: 696f 6e73 5d0a 6c6f 6361 7469 6f6e 3a20  ions].location:
00000120: 7472 7565 0a6f 7574 7075 743a 202e 2f68  true.output: ./h
00000130: 7572 6c5f 7b7b 7665 7273 696f 6e7d 7d5f  url_{{version}}_
00000140: 616d 6436 342e 6465 620a                 amd64.deb.

@jcamiel
Copy link
Collaborator

jcamiel commented Mar 16, 2024

Hi @CodeMan99

Thanks for the detailed issue, it looks like a bug! Nice catch!

@CodeMan99
Copy link
Author

@jcamiel

Best I tell it seems to be triggered by having any text after the variable placeholder.

@jcamiel jcamiel added this to the 4.3.0 milestone Mar 17, 2024
@jcamiel jcamiel linked a pull request Mar 17, 2024 that will close this issue
@jcamiel
Copy link
Collaborator

jcamiel commented Mar 17, 2024

Thanks again for the report @CodeMan99 , this was more than a format issue. The parsing logic for filename with variables was buggy and should be fixed by #2545.

@CodeMan99
Copy link
Author

Very nice! Code changes look sane to me. That said I have zero context as I've really only glanced at the format code.

I'm alright with Rust, but it takes more than a once-over to grasp :)

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