model-registry
model-registry copied to clipboard
/api/model_registry/v1alpha3/registered_models responseBody for 401 is not following json schema
Describe the bug /api/model_registry/v1alpha3/registered_models responseBody for 401 is not following json schema
To Reproduce Steps to reproduce the behavior:
- Run:
curl -i -X POST "localhost:8080/api/model_registry/v1alpha3/registered_models" \
-H "Content-Type: application/json" \
-d '{
"description": "dora description1",
"externald": "9918",
"name": "dora1",
"owner": "eder",
"stat1e": "LIVE", "lastUpdateTimeSinceEpoch": "1"
}'
You get the response:
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Vary: Origin
Date: Wed, 15 May 2024 19:26:43 GMT
Content-Length: 36
"json: unknown field \"externald\""
Expected behavior
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Vary: Origin
Date: Wed, 15 May 2024 19:26:43 GMT
Content-Length: 36
{
"code": "HTTP Code",
"message": "Some error message"
}
Additional context
Also, for some errors, the "code" is being empty and not populated with error code. I'm able to reproduce this with error 500 (running the same post twice).
If you confirm this is a valid issue, I can try to send a PR to fix it.
If you confirm this is a valid issue, I can try to send a PR to fix it.
I'm a bit perplexed why it didn't return you openapi.Error 🤔
I'd advise for this after https://github.com/kubeflow/model-registry/pull/93
btw,
Also, for some errors, the "code" is being empty and not populated with error code. I'm able to reproduce this with error 500 (running the same post twice).
the code in the body was not meant to reflect the http-status-code, but a placeholder if UI wanted to define their own codes.
@tarilabs, as soon as https://github.com/kubeflow/model-registry/pull/93 is merged, I'll see if I can still reproduce this.
Looking at the example there seem to be 2 typos. I'm also afraid lastUpdateTimeSinceEpoch isn't/wasn't a user-settable field, at least not in this call. Ref: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml#/ModelRegistryService/createRegisteredModel
curl -i -X POST "localhost:8080/api/model_registry/v1alpha3/registered_models" \
-H "Content-Type: application/json" \
-d '{
"description": "dora description1",
- "externald": "9918",
+ "externalId": "9918",
"name": "dora1",
"owner": "eder",
- "stat1e": "LIVE", "lastUpdateTimeSinceEpoch": "1"
+ "state": "LIVE"
}'
Looking at the example there seem to be 2 typos
I believe the typos @isinyaaa were intentional in order to trigger the error from the backend 🤔
Oh sorry, I missed that.
No worries, this is definitely worth checking, I mean that the server in case of error is respecting the OpenAPI contract fully.
Now I see the for 401 in the title, I misinterpreted. But are we talking about getting the wrong status or the wrong response? I believe there are still some TODOs related to 401 responses left, but this looks like we have two issues, as the responses also don't comply with the listed schema (which I completely missed 😅 ).
@isinyaaa, the typos are to create the reproducers for the issue. I also made a mistake on the title as I believe that 400 is the correct error code. wdyt?
I would suggest to focus this issue to return the correct schema in any bad request.