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

Specifying --resource-types gives IndexError: list index out of range #16

Open
rgarner opened this issue May 1, 2024 · 4 comments
Open

Comments

@rgarner
Copy link

rgarner commented May 1, 2024

har2locust --resource-types document,xhr performance/an_undergraduate_student_joins.har > performance/an_undergraduate_student_joins.py

yields

Traceback (most recent call last):
  File "/Users/russ/.pyenv/versions/3.12.0/bin/har2locust", line 8, in <module>
    sys.exit(__main__())
             ^^^^^^^^^^
  File "/Users/russ/.pyenv/versions/3.12.0/lib/python3.12/site-packages/har2locust/__main__.py", line 29, in __main__
    template_values = process(har, args)
                      ^^^^^^^^^^^^^^^^^^
  File "/Users/russ/.pyenv/versions/3.12.0/lib/python3.12/site-packages/har2locust/__main__.py", line 77, in process
    values |= p(entries, args) or {}
              ^^^^^^^^^^^^^^^^
  File "/Users/russ/.pyenv/versions/3.12.0/lib/python3.12/site-packages/har2locust/default_plugins/default_headers.py", line 39, in default_headers
    urlparts = urlsplit(entries[0]["request"]["url"])
                        ~~~~~~~^^^
IndexError: list index out of range

Removing the --resource-types param generates the script. Also, adding the default har2locust --resource-types xhr,document,other performance/an_undergraduate_student_joins.har > performance/an_undergraduate_student_joins.py generates the script with no errors.

@ivanpuchalka
Copy link
Contributor

It looks like your HAR file has no resources of those types so after filtering, the entry list ends up empty and causes the error in another plugin. Maybe an explicit error should be thrown if there are no entries after executing an entries processor?

@cyberw
Copy link
Collaborator

cyberw commented Jun 1, 2024

PR very welcome

@rgarner
Copy link
Author

rgarner commented Jun 9, 2024

@cyberw I would like to be able to contribute, but I'm mostly Ruby. My Python will need to get a lot better for me not to embarrass myself. I like that it got a little better after using this and Locust, and I love that Locust makes me want to make my Python good enough to do this, so I might be able to do it, but it might take cough some time...

@cyberw
Copy link
Collaborator

cyberw commented Jun 9, 2024

I understand :)

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

3 participants