Skip to content

Checking for requests.Response.reason is less reliable than requests.Response.status_code #947

@mfocko

Description

@mfocko

What happened? What is the problem?

Tests are red…

        if not result or result.reason == "NOT FOUND":
            raise FileNotFoundError(f"File '{path}' on {ref} not found")
        if result.reason != "OK":
>           raise PagureAPIException(
                f"File '{path}' on {ref} not found due to {result.reason}",
            )
E           ogr.exceptions.PagureAPIException: File 'python-teamcity-messages.spec' on HEAD not found due to Not Found

Checking for NOT FOUND is not guaranteed, apparently it is also possible to get the same reason but in different caps…

What did you expect to happen?

Get a proper FileNotFoundError exception instead of the generic PagureAPIException

Example URL(s)

https://softwarefactory-project.io/zuul/t/packit-service/build/24e60f08c1e546348a62f5e3b7ae1bdc/console

Steps to reproduce

Run tests in Packit Service…

Workaround

  • There is an existing workaround that can be used until this issue is fixed.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)

Metadata

Metadata

Assignees

Labels

kind/bugAn unexpected problem or behavior

Type

Projects

Status

done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions