DEV Community

TheoForger
TheoForger

Posted on

Sprint 1 - Research Time!

Our first 2-week sprint came to an end. During this week, not much happened code-wise. However, working on these projects had led me to some interesting findings. And I'll be sharing all that right here!

🌐 Hurl

(Link to PR)

This would be my last PR regarding the header option feature. And I'm happy to report that I'm officially responsible for and in charge of this feature ðŸĪŠ!

This PR was essentially the reverse of the previous one. This time, my contribution was to hurlfmt. This tool, among other features, allows you to convert curl commands to hurl files. I enabled it to handle empty headers in this process. For example, if you prepare a file named example:

# file: example
curl --header 'Empty-Header;' https://httpbin.org/status/200
Enter fullscreen mode Exit fullscreen mode

and run:

$ hurlfmt --in curl example
Enter fullscreen mode Exit fullscreen mode

You'll get the same request in hurl file format (Notice that ; is replaced with :):

GET https://httpbin.org/status/200
Empty-Header:
Enter fullscreen mode Exit fullscreen mode

Rust Stuff

Something interesting I encountered with clippy: In my initial implementation, I used a combination of ends_with() and slicing, like so:

for header in headers {
    let trimmed_header = header.trim();
    if trimmed_header.ends_with(";") {
        s.push_str(format!("\n{}:", &trimmed_header[..trimmed_header.len() - 1]).as_str());
    } else {
      ...
    }
}
Enter fullscreen mode Exit fullscreen mode

And once again, the Rust toolchain took babysitting to another level:
Clippy suggesting .strip_suffix()
The suggested fix used the if let pattern matching syntax and the strip_suffix method. If the header ends with an ;, it will match Option::Some, and then I can use the stripped string for the new format. Perfect! I appreciate how the linter always encourages you to do things "the Rust way".

Time to Investigate!

During my development, I discovered a bug where if I use a file like the example above, hurlfmt would simple panic. Later, I realized that it happens to any invalid headers. I decided to look into this.

Time to use the good old debugger! After many breakpoints and step-overs, I narrowed down the cause to the request parser. Seems like if a header is not parsed properly, the parser would terminate early and assume the rest belongs to a different request. And of course, the text that follows does not actually define a new request - This causes the program to panic.

To better explain this, I ran hurlfmt twice and recorded the cursor positions after parsing the requests. Here are the results:

With a valid header With an invalid header
The parser terminated at the end of the text The parser terminated early
The parser terminated at the end of the text The parser terminated early

And if we look closer, we can find that the parser stopped right before the invalid header. Here's index 55 in the buffer:
parser stopped right before the invalid header

Since this part of the code was complete new territory to me, I filed an issue and hoped the maintainers would have more ideas about this. So far there haven't been any updates. But we'll see how this goes.

🌠 Starchart

(Link to PR)

After last week's decision to switch from ESLint to Oxc, I've been doing research. For the most part, this is a very straightforward project. I simply removed all the ESLint dependencies and added oxlint to the list. Everything seemed to work, mostly.

To migrate the configurations, I referred to their official documentation. The Ocx linter has a very similar configuration file to ESLint. For the most part, I just copied over the specs from the original file, except for this one section:

  extends: [
    '@remix-run/eslint-config',
    '@remix-run/eslint-config/node',
    'plugin:playwright/playwright-test',
    'prettier',
  ],
Enter fullscreen mode Exit fullscreen mode

Apparently, Oxc still doesn't support the extend option. Although the linter runs just fine without it, I'm not sure if this will lead to any problems in the future.

Plans for Sprint 2

Hurl - Support ip query for getting resolved response IP

(#3106)
For this issue I'll implement a new feature to allow users to assert the IP address for each response. This is going to be a new chapter for me since I'll be working on a different part of the project. I spent the last few months with options and requests, but this will be all about responses. Can't wait to find out what I'll learn next!

Starchart - ???

Since this is my 20% focus and I'm not super familiar with this project, I asked the class for recommendations during this week's sprint meeting. The professor mentioned there's a bug where certain CSS doesn't load. However, there's no recorded steps to reproduce. I'll work with the other folks on this project and see if we can figure out the cause.

Top comments (0)