Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/127.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CTL: `schema load` return a proper error message when authentication is missing or when the user doesn't have the permission to update the schema.
10 changes: 6 additions & 4 deletions infrahub_sdk/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,12 @@ def _validate_load_schema_response(response: httpx.Response) -> SchemaLoadRespon
status = response.json()
return SchemaLoadResponse(hash=status["hash"], previous_hash=status["previous_hash"])

if response.status_code == httpx.codes.BAD_REQUEST:
return SchemaLoadResponse(errors=response.json())

if response.status_code == httpx.codes.UNPROCESSABLE_ENTITY:
if response.status_code in [
httpx.codes.BAD_REQUEST,
httpx.codes.UNPROCESSABLE_ENTITY,
httpx.codes.UNAUTHORIZED,
httpx.codes.FORBIDDEN,
]:
return SchemaLoadResponse(errors=response.json())

response.raise_for_status()
Expand Down