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

ArtifactoryException: File not found #437

Closed
ailinykh opened this issue Dec 11, 2023 · 1 comment
Closed

ArtifactoryException: File not found #437

ailinykh opened this issue Dec 11, 2023 · 1 comment

Comments

@ailinykh
Copy link
Contributor

Sometimes path.exists() throws an exception in case file not exists:

File "main.py", line 39, in upload
      if not path.parent.exists():
             ^^^^^^^^^^^^^^^^^^^^
    File "/some/path/lib/python3.11/pathlib.py", line 1235, in exists
      self.stat()
    File "/some/path/lib/python3.11/site-packages/artifactory.py", line 1637, in stat
      return self._accessor.stat(pathobj=pathobj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/some/path/lib/python3.11/site-packages/artifactory.py", line 892, in stat
      jsn = self.get_stat_json(pathobj)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/some/path/lib/python3.11/site-packages/artifactory.py", line 883, in get_stat_json
      raise_for_status(response)
    File "/some/path/lib/python3.11/site-packages/dohq_artifactory/exception.py", line 39, in raise_for_status
      raise ArtifactoryException(error_info_dict["message"]) from exception
  dohq_artifactory.exception.ArtifactoryException: File not found.

the main reason of this behaviour is that artifactory may respond with two kinds of json:

{
  "errors" : [ {
    "status" : 404,
    "message" : "Unable to find item"
  } ]
}

the first one is handled gracefully and we raising an OSError

{
  "errors" : [ {
    "status" : 404,
    "message" : "File not found."
  } ]
}

but the second one does not meet condition and causes an exception above

ailinykh added a commit to ailinykh/artifactory that referenced this issue Dec 11, 2023
allburov added a commit that referenced this issue Dec 12, 2023
* Handle "File not found." artifactory response as OSError

Fix for #437

* Apply suggestions from code review

Co-authored-by: Anthony Ilinykh <[email protected]>

---------

Co-authored-by: Alex <[email protected]>
@allburov
Copy link
Member

Hi! It's been released as I can see in 0.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants