mapbox / mapbox-gl-style-spec

76 stars 38 forks source link

GL Style JSON fails PATCH validation #439

Closed cmtoomey closed 7 years ago

cmtoomey commented 8 years ago

In testing PATCH requests against GL Styles, the Style JSON provided by GET /styles/v1/{username}/{style_id} is not valid for PATCH requests made via PATCH /styles/v1/{username}/{style_id}.

Actual request (with body) can be found here

HTTP Response code is 422 Unprocessable Entity

Postman output below

image

If "created" is deleted, the PATCH request fails again due to "modified"

image

Deleting "modified" allows the request to go through

image


Two requests for fix:

  1. Remove "created" and "modified" from GET request output (hard to trace, so not preferred)
  2. Update JSON validation for Style API PATCH to accept those JSON key/value pairs.
tmcw commented 8 years ago

This is fully covered by API documentation, so the behavior should not come as a surprise: https://www.mapbox.com/api-documentation/#update-a-style

Requesting a style and then using the same content to update the style will fail: you'll need to remove the created and modified properties before updating a style. The name property, which is optional for style creation, is required when updating a style. Cross-version PATCH requests are rejected.

cmtoomey commented 8 years ago

That's fair - but I'm curious as to the existence of the behavior in the first place. Based on the style-reference, created and modified aren't actually part of the spec - which is logical given the documentation and expected behavior.

However, the initial interaction with the Style JSON returns something that is off-spec. I get that parsing and deleting lines isn't a massive technical undertaking; but if we accept that creation and modification dates are useful properties (else they wouldn't be provided), wouldn't it be easier to simply adopt them into the spec?

lucaswoj commented 7 years ago

This has been addressed with the metadata property

jfirebaugh commented 7 years ago

I think this is still valid -- the Style API doesn't actually use metadata for these properties, due to historical timing. We could decrease the API friction and eliminate the documentation caveat by adding them to the style spec, so that the Style API response validates.

lucaswoj commented 7 years ago

This issue was moved to mapbox/mapbox-gl-js#4114