department-for-transport-public / D-TRO

Digital Traffic Regulation Orders (D-TRO)
MIT License
3 stars 1 forks source link

Misleading validation message on submitting malformed Geometry #26

Open davidgruar opened 2 weeks ago

davidgruar commented 2 weeks ago

I attempted to create a DTRO via the createFromFile endpoint that included a regulatedPlace looking something like this:

{
  "geometry": {
    "version": 1,
    "Polygon": {
      "polygon": "SRID=27700;POLYGON ((436870.12 389453.97, 436870.81 389454.55, 436871.85 389455.58, 436870.12 389453.97))",
      "externalReference": []
    }
  }
}

I got back a 400 response with the following body:

{"ruleError_0":{"name":"Spatial reference","message":"British National Grid - Spatial Reference not present in the geometry or it is wrong referenced.","path":"Source.provision.regulatedPlace.geometry","rule":"Spatial reference should be SRID=27700"}}

This caused me a good deal of confusion, as the geometry was specified with SRID=27700 as required. I eventually worked out that the externalReference property was at the wrong level (for reasons mentioned in #25), and should have been a child of "geometry" and a sibling of "version" and "Polygon". When I fixed this I was able to submit the request successfully.

There is clearly something wrong with the validation if it is reporting errors that are not present and not reporting the actual error.

stm-john-cooper commented 2 weeks ago

Thanks for raising this issue. We will investigate and get back to you.

stm-john-cooper commented 2 days ago

This issue has been added to the backlog.