Repository navigation
XCPNG-3989: Commit message list upstream - #7361
Open
contificate wants to merge 6 commits into
Open
contificate wants to merge 6 commits into
contificate wants to merge 6 commits into
Conversation
Each released message can be emitted with api_compat.exe. The format is line-delimited JSON (often saved as .ndjson). You can `dune exec ./ocaml/idl/api_compat.exe -- -print` to see the messages printed to stdout. The intention is that we'll emit this to a file, committed upstream, and then add a test that compares the contents for mutations. Signed-off-by: Colin James <contificate@gmail.com>
Adds a simple parser for the line-delimited JSON format introduced previously. Signed-off-by: Colin James <contificate@gmail.com>
last-genius
approved these changes
Oct 29, 2026
last-genius
left a comment
Contributor
There was a problem hiding this comment.
Unlike the existing check, this also covers objects without any params with defaults, and checks for ordering changes. The error messages are helpful and clear - this is a welcome improvement, thank you!
Commits the current messages file to the repository. This was done via redirecting `dune exec ./ocaml/idl/api_compat.exe -- -print` to ocaml/idl/messages.ndjson. Signed-off-by: Colin James <contificate@gmail.com>
You can now invoke api_compat.exe with `-check <file>` and it will compare the datamodel against this file. We perform a pairwise comparison of message parameters to catch various potential mutations that may have occurred when modifying the datamodel. E.g. changing a parameter's default value, a message's return type, permuting the order of parameters, adding a parameter (at the end) that lacks a default, etc. The next step is to turn this into a workflow compatible with dune. Signed-off-by: Colin James <contificate@gmail.com>
Generates a messages.ndjson.generated in the dune build directory, which can then be compared against what's currently there (for promotion purposes), along with turning api_compat's -check mode into a test. We also add a promotion rule alias. Signed-off-by: Colin James <contificate@gmail.com>
Similar to datamodel_lifecycle.ml, we check the generated messages list against the one currently committed in the repository. If the check fails, we abandon. Otherwise, we automatically do promotion (applying the diff to the worktree). Signed-off-by: Colin James <contificate@gmail.com>
contificate
force-pushed
the
cbarr/master/messages
branch
from
October 29, 2026 09:57
f599518 to
bf4f95e
Compare
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.
This is a proof-of-concept of catching various breaking changes to XenAPI. This is quite a niche safety net as it captures 2 cases that aren't captured by the building of Xapi:
Other larger changes will have to be confronted when you attempt to build the rest of Xapi. However, committing the message list upstream has some idealistic benefits: (1) there's enough information in the generated message listing to produce a typed XenAPI client (this is the approach taken in my xapy project, which uses the documentation's
xenapi.jsonfile), (2) by committing messages upstream, it forces the repository state and commits to be obvious about what messages have been changed (along with the possibility, in future, of easily seeing what messages are present between version tags, as they'll be noted upstream).This work was inspired by 0416e2a (which I came across when generalising optional arguments to permit omission anywhere). This PR subsumes this check and also captures the part that was lacking: new parameters are now detected by comparison against the committed message list (snapshot), so it'll fail the build if you don't promote it (and accept it as a breaking change to the API). Of course, doing such a change requires changing the implementation code, but this makes PR makes it obvious to the developer that they should provide defaults for any new arguments they're appending to extant messages.
As an example of how this works: suppose you permute the ordering of
login_with_password(uname, pwd, ...)so that the password comes before the username:Upon trying to build this change, you will be confronting with:
You can then accept this breaking change (with
dune build @ocaml/idl/update-messages --auto-promote):with this promotion, the check will pass, and you'll be able to build the rest of the toolstack. The other category of change required here is the changing of a parameter's default value. For example, modifying the default
originatorinlogin_with_password(uname, pwd, version, originator)to"foo"will error as:As clients may rely on a default value (unlikely in this exact case), it is a breaking change, so this PR makes that explicit.