Repository navigation
Conversation
API specifications were decoded into Go maps on both sides, so the stored YAML had alphabetically sorted keys, 4-space indentation, and integers of 1,000,000 or more written as 1e+06. Reading a specification back returned its keys in random order. rover-ctl now decodes YAML once in ordered mode and sends the specification as JSON in source order. rover-server keeps the specification as raw JSON and converts it with goccy/go-yaml into 2-space YAML in the same order, and back into JSON in stored order on read. roverctl resource get/list keeps the server's order in its output. Existing specifications get a new hash and are uploaded once more on their next apply; the file ID and the Api resource stay the same. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
API specifications now keep the author's key order end to end:
specificationasjson.RawMessage(x-go-typeinapi/openapi.yaml, request and response).specToYAMLconverts it with goccy into 2-space YAML in the same order. That YAML is hashed, linted and uploaded to the file-manager. On read,specToJSONreturns the stored YAML as JSON in stored order.roverctl resource get/listkeep responses asjson.RawMessage, so their JSON and YAML output shows the server's order for every resource type.Why
Before, both sides decoded specifications into Go maps. As a result:
1e+06, which libopenapi reads as0for fields likemaxLength.GETreturned keys in random order, because sonic doesn't sort map keys.What reviewers should know
Apiresource is unchanged. After that, unchanged specs hit the hash shortcut again.nullor non-object specifications are now rejected with400.1.50is stored as1.5.1e+06comes back fromGETas a string, which also affects old specs until they're applied again."<<"is read back as a merge key.GETto fail with a 500 instead of returning invalid JSON.go.mod, at the same version.user-journey/exposing-apis.mdxdescribes how a specification is stored and corrects the old claim that it is "stored unchanged".architecture/rover.mdxdescribes the format.Verification
make testpasses in rover-ctl and rover-server (controller suite 345/345), including new tests for both conversion helpers, the upload bytes, the read-back order,roverctl resource getoutput order and the anchor tests from0cb6605b.