Skip to content

Feat/verify http error codes#145

Merged
Urist-McGit merged 3 commits intosiemens:mainfrom
tamilari:feat/verify-http-error-codes
Dec 4, 2025
Merged

Feat/verify http error codes#145
Urist-McGit merged 3 commits intosiemens:mainfrom
tamilari:feat/verify-http-error-codes

Conversation

@tamilari
Copy link
Contributor

@tamilari tamilari commented Dec 4, 2025

Introduces a new get helper function to centralize HTTP requests to
the snapshot client. This helper now validates the response's HTTP
status code. A 404 error code will raise a NotFoundOnSnapshotError.
All other client or server error codes will be caught by the
raise_for_status function from the requests library and subsequently
re-raised as a SnapshotDataLakeError. The only remaining status codes
that the snapshot client is expected to return are 200 and 304, where
the latter one cannot be returned, as an If-Modified-Since header is
never specified. This implies that if no error is raised, the status
code is 200 and the output is in the expected format.

This prevents silent failures and subsequent issues like incorrect JSON
parsing when the API returns unexpected content, ensuring earlier and
clearer error detection. It also reduces the need for repetitive status
code checks at each call site.

Introduces a new `get` helper function to centralize HTTP requests to
the snapshot client. This helper now validates the response's HTTP
status code. A 404 error code will raise a `NotFoundOnSnapshotError`.
All other client or server error codes will be caught by the
`raise_for_status` function from the `requests` library and subsequently
re-raised as a `SnapshotDataLakeError`. The only remaining status codes
that the snapshot client is expected to return are 200 and 304, where
the latter one cannot be returned, as an `If-Modified-Since` header is
never specified. This implies that if no error is raised, the status
code is 200 and the output is in the expected format.

This prevents silent failures and subsequent issues like incorrect JSON
parsing when the API returns unexpected content, ensuring earlier and
clearer error detection. It also reduces the need for repetitive status
code checks at each call site.

Signed-off-by: Tamino Larisch <tamino.larisch@siemens.com>
Reapply checksum-related changes that were likely lost during a rebase.

Signed-off-by: Tamino Larisch <tamino.larisch@siemens.com>
Replace the last occurrence of the manual package string formatting
`{srcpkg.name}@{srcpkg.version}` with its string representation.

Signed-off-by: Tamino Larisch <tamino.larisch@siemens.com>
@Urist-McGit
Copy link
Collaborator

Pretty sure I created the mess you fixed in 8769100, so thank you for fixing that ;)

@Urist-McGit Urist-McGit self-requested a review December 4, 2025 09:58
@Urist-McGit Urist-McGit merged commit ea3bc6d into siemens:main Dec 4, 2025
14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants