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

Issue when referencing request by @name in multiple files #508

Closed
Nick-Palacio opened this issue Jul 24, 2023 · 4 comments
Closed

Issue when referencing request by @name in multiple files #508

Nick-Palacio opened this issue Jul 24, 2023 · 4 comments

Comments

@Nick-Palacio
Copy link

Nick-Palacio commented Jul 24, 2023

Hello,

I am seeing an issue where if I try to reference the same request by name in multiple files, whatever file is run after the first one fails to reference that request with an error ref {myNamedRequest} not found.

Steps to reproduce:

  1. In a folder create the following files:
    • ./setupFile.http
      # @name json
      GET https://postman-echo.com/get
      
    • ./setupFile2.http
       # @import ./setupFile.http
       
       # @name json2
       # @ref json
       GET https://postman-echo.com/get
      
    • ./test.http
       # @import ./setupFile.http
       # @import ./setupFile2.http
       
       # @ref json
       # @ref json2
       POST https://postman-echo.com/post
       {{json.url}}
      
  2. From this folder run httpyac send ./*.http --all
  3. See test2.http fail with message ref json not found

My use case here is that I have separate HTTP files that do some setup for a suite of integration tests, one that gets an access token and one that creates some test data for the test. Both need to set variables that can be used by the other test files so I was trying to add a @ref metadata to both setup requests in my test files which led me to this issue.

@AnWeber
Copy link
Owner

AnWeber commented Jul 25, 2023

@Nick-Palacio I could not reproduce it currently. I have used the following files

./name.http

# @name json
GET https://postman-echo.com/get

./test.http and ./test2.http

# @import ./name.http
# @ref json
POST https://postman-echo.com/post
{{json.url}}

All requests were executed successfully using httpyac send **/*.http --all --output short. As soon as I remove the
# @import I get an error that ref json was not found. Can this be your problem? But error occurs already at the 1st request and not as described at the 2nd request.

@Nick-Palacio
Copy link
Author

Apologies @AnWeber, I've updated the steps to reproduce above with the correct setup to trigger this issue. Let me know if you are able to reproduce now.

@AnWeber
Copy link
Owner

AnWeber commented Jul 25, 2023

Yes, thank you. So it makes sense and I can reproduce it. The cause was a missing mapping that the file was also imported in ./test.http. I have added this. I noticed another error in the log output that I want to check to see if I can fix that right away as well. And would then release it soon.

@AnWeber
Copy link
Owner

AnWeber commented Jul 25, 2023

fixed with v6.6.3

@AnWeber AnWeber closed this as completed Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants