Skip to content

Consider using boolean flag for compatible API #68100

Closed
@pgomulka

Description

@pgomulka

At the moment Compatible REST API is implemented to register compatible endpoints under a N-1 version. This means that RestRequest has a version that allows routing to a Rest Action registered under a path, method and version.
The idea suggested during review of #68047 is to refactor this to only use a boolean flag.
The benefit is that it simplifies the code and does allow to confuse developers that Compatible API could be registered under a minor version. We only support N-1 version so just a flag feels natural.

However the downside is the scenario during release period. As per my comment here

Let's say we released a version 8, we won't be able to differentiate the code that was meant to be compatible with 7 and the code that was introduced after feature freeze and was meant to be compatible with 8 (talking to ES9)
Having only a flag would mean that work on future (compatible with 8 when the ES8 was just released) compatible code would be impossible until all the "old" (compatible with 7) code is removed.
I think it would also be prone to be accidentally missed and could be incorrectly considered to be compatible with 8.

My suggestion is to register REST endpoints under a version (current behaviour) and use a "wire protocol pattern" for surgical compatible changes. In order avoid the problem of possible confusion that a compatible api could support a minor we could introduce a separate version wrapper CompatibleAPIVersion. This object could then be used to find all the compatible API changes that need to be removed after the release.

if(xcontentBuilder.compatibleVersion() == CompatibleAPIVersion.7)

cc @jakelandis

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions