Skip to content

Commit b32796f

Browse files
authored
Merge pull request #144 from opsmill/dga-20241116-fix-127
Return a proper error message when executing `schema load` with the wrong credential
2 parents d601580 + 6fa2272 commit b32796f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

changelog/127.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

infrahub_sdk/schema.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,12 @@ def _validate_load_schema_response(response: httpx.Response) -> SchemaLoadRespon
539539
status = response.json()
540540
return SchemaLoadResponse(hash=status["hash"], previous_hash=status["previous_hash"])
541541

542-
if response.status_code == httpx.codes.BAD_REQUEST:
543-
return SchemaLoadResponse(errors=response.json())
544-
545-
if response.status_code == httpx.codes.UNPROCESSABLE_ENTITY:
542+
if response.status_code in [
543+
httpx.codes.BAD_REQUEST,
544+
httpx.codes.UNPROCESSABLE_ENTITY,
545+
httpx.codes.UNAUTHORIZED,
546+
httpx.codes.FORBIDDEN,
547+
]:
546548
return SchemaLoadResponse(errors=response.json())
547549

548550
response.raise_for_status()

0 commit comments

Comments
 (0)