Skip to content

Better errors formatting in config API response #191

@Alex-D

Description

@Alex-D

For now, we have an endpoint /api/v1/config that returns something like this:

{
  "version": 1,
  "tiles": [
    {"type": "EMPTYYYY"}
  ],
  "errors": ["Unsupported version", "Columns field is missing", "Unknown tile type EMPTYYYY"]
}

That way, we mix config itself and errors added by the Core's Verify method.

For better errors management, we need to:

  • split config and errors
  • add a unique ID also used as a translation key
  • get the raw value which causes the error (configUrl, specific tile's JSON, ...)

With that in mind, we can go to something more like that:

{
  "config": {
    "version": 1,
    "tiles": [
      {"type": "EMPTYYYY"}
    ]
  },
  "errors": [
    {
      "id": "ERROR_UNSUPPORTED_VERSION",
      "message": "Unsupported version",
      "data": {
        "configExtract": "{\"version\": 1}",
        "expected": ">= 4"
      }
    },
    {
      "id": "ERROR_MISSING_REQUIRED_FIELD",
      "message": "Columns field is missing",
      "data": {
        "fieldName": "columns",
        "expected": ">= 1"
      }
    },
    {
      "id": "ERROR_UNKNOWN_TILE_TYPE",
      "message": "Unknown tile type EMPTYYYY",
      "data": {
        "configExtract": "{\"type\": \"EMPTYYYY\"}",
        "expected": "EMPTY, GROUP, PING, PORT, [...]"
      }
    }
  ]
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions