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

Failure to parse hostname in after-response script #8049

Open
1 task done
devguydavid opened this issue Oct 5, 2024 · 4 comments
Open
1 task done

Failure to parse hostname in after-response script #8049

devguydavid opened this issue Oct 5, 2024 · 4 comments
Labels
C-improvement Category: Improvement / Enhancement S-verified Status: Verified by maintainer

Comments

@devguydavid
Copy link

Expected Behavior

Parsing of the response succeeds

Actual Behavior

This error:

Unexpected Request Failure

The request failed due to an unhandled error:

Execute after-response script failed: Error: Error: new Url(): failed to parse hostname in url ${urlStr}

Reproduction Steps

  1. Add a GET request that returns the full URL in a json response body property. For example, a call that returns this:
{
  "url": "https://google.com"
}
  1. Add a PUT request that uses the full URL by referencing the Response -> Body Attribute of "url" returned by the request in step 1 as its endpoint to call.
  2. Call the two endpoints in sequential order.

Is there an existing issue for this?

Additional Information

Here is a collection that exhibits the error using mocky.io:

Reproduce Hostname Parsing Error.json

Insomnia Version

10.0.0

What operating system are you using?

macOS

Operating System Version

Mac OS Sequoia 15.0

Installation method

dmg downloaded from the website

Last Known Working Insomnia version

No response

@devguydavid devguydavid added B-bug Bug: general classification S-unverified Status: Unverified by maintainer labels Oct 5, 2024
@devguydavid
Copy link
Author

devguydavid commented Oct 5, 2024

It looks like parse in urls.ts is being passed the raw value instead of the resolved URL:

{% response 'body', 'req_3a1b3b4368a14cd59b53656d37022415', 'b64::JC51cmw=::46b', 'never', 60 %}

@subnetmarco
Copy link
Member

@ihexxa

@ihexxa
Copy link
Contributor

ihexxa commented Oct 8, 2024

Hello @devguydavid, you are seeing {% ... %} because template tags (such as your case or environment tags) are evaluated after the pre-request script step. Probably you could try insomnia.environment.set('url', url) and access it in the next request at the moment and we will take a look at it, as currently there seems no quick and elegant way to handle this.

@devguydavid
Copy link
Author

Yes, thank you, that is a fine workaround. One of the things I love about Insomnia is not needing to use environment variables for passing data around (looking at you, Postman), but in a pinch it works!

@ihexxa ihexxa added C-improvement Category: Improvement / Enhancement S-verified Status: Verified by maintainer and removed B-bug Bug: general classification S-unverified Status: Unverified by maintainer labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-improvement Category: Improvement / Enhancement S-verified Status: Verified by maintainer
Projects
None yet
Development

No branches or pull requests

3 participants