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

query on how to handle HTTPError: 401 Client Error: Invalid password/token for user #861

Open
mlsxdx opened this issue Jul 3, 2024 · 0 comments

Comments

@mlsxdx
Copy link

mlsxdx commented Jul 3, 2024

ISSUE TYPE
  • How to handle requests.exceptions.HTTPError: 401 Client Error
Jenkinsapi VERSION

0.3.11

Jenkins VERSION

2.164.2

SUMMARY

Recently my jenkinsapi complains HTTPError: 401 Client Error: Invalid password/token for user:
I want to know how to add this exception handling in my program.

EXPECTED RESULTS

When this HTTPError: 401 Client Error occurs, retry it(call build.get_data() again)

ACTUAL RESULTS

Just want to get some input on how to implement such in my program.
Currently I am using block_until_complete(delay=300) in build.py to poll the build status.

build.block_until_complete(delay=300)
USEFUL INFORMATION

I want to have similar function to override is_running(self) in build.py which can handle HTTPError: 401

ERROR:jenkinsapi.jenkinsbase:Failed request at http://jen/job/huracan_check_in/4730/api/python with params: {'depth': 1, 'tree': 'building'} building
Traceback (most recent call last):
  File "/home/tma/TRY/TryPython/TryAutoPush/jks_bp.py", line 121, in <module>
    build.block_until_complete(delay=300)
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/build.py", line 417, in block_until_complete
    while self.is_running():
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/build.py", line 399, in is_running
    data = self.poll(tree='building')
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/jenkinsbase.py", line 60, in poll
    data = self._poll(tree=tree)
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/build.py", line 63, in _poll
    return self.get_data(url, params={'depth': self.depth}, tree=tree)
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/jenkinsbase.py", line 84, in get_data
    response.raise_for_status()
  File "/home/tma/.local/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Invalid password/token for user: tma for url: http://jen/job/huracan_check_in/4730/api/python?depth=1&tree=building
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

1 participant