TritonDataCenter / sdc-imgapi

SDC internal API for managing OS images
Mozilla Public License 2.0
5 stars 18 forks source link

TRITON-2345 Return accurate error when attempting to import an invalid img alias #48

Closed travispaul closed 1 year ago

travispaul commented 1 year ago

The example lxd image alias in the docs is incorrectly formatted and returns the following error:

{
  "type": "error",
  "id": "debian/11/cloud",
  "error": {
    "code": "InvalidParameter",
    "message": "No registry found for \"undefined\" - valid registries are \"images, ubuntu\""
  },
  "alias": "debian/11/cloud"
}

This PR propagates the actual error when a registry is absent, resulting in the following error message:

{
  "code": "InvalidParameter",
  "message": "alias must be in the format \"registry:image\"",
  "errors": [
    {
      "field": "alias",
      "code": "InvalidParameter"
    }
  ]
}

Additional testing notes on TRITON-2345

travispaul commented 1 year ago

Yeah, I think this will be better. Do you need to re-run any of the tests?

I reran the tests and make check. Both continue to pass.