model-registry icon indicating copy to clipboard operation
model-registry copied to clipboard

/api/model_registry/v1alpha3/registered_models responseBody for 401 is not following json schema

Open ederign opened this issue 1 year ago • 4 comments

Describe the bug /api/model_registry/v1alpha3/registered_models responseBody for 401 is not following json schema

To Reproduce Steps to reproduce the behavior:

  1. 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).

ederign avatar May 15 '24 19:05 ederign

If you confirm this is a valid issue, I can try to send a PR to fix it.

ederign avatar May 15 '24 19:05 ederign

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

tarilabs avatar May 15 '24 19:05 tarilabs

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 avatar May 16 '24 09:05 tarilabs

@tarilabs, as soon as https://github.com/kubeflow/model-registry/pull/93 is merged, I'll see if I can still reproduce this.

ederign avatar May 16 '24 12:05 ederign

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"
}'

isinyaaa avatar Jul 16 '24 15:07 isinyaaa

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 🤔

tarilabs avatar Jul 16 '24 15:07 tarilabs

Oh sorry, I missed that.

isinyaaa avatar Jul 16 '24 15:07 isinyaaa

No worries, this is definitely worth checking, I mean that the server in case of error is respecting the OpenAPI contract fully.

tarilabs avatar Jul 16 '24 15:07 tarilabs

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 avatar Jul 16 '24 15:07 isinyaaa

@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.

ederign avatar Jul 18 '24 11:07 ederign