In plugin/api.go, we document the minimum required server version to use an API, e.g.:
This means that the API was first added to Mattermost 5.8, and simply won't be available in earlier versions. Methods without an explicit comment are implicitly supported in Mattermost 5.2 and later, though this is being separately improved as part of .
In plugin/helpers.go, we do the same thing:
The helpers API is not exposed in a running server – the helpers may be compiled into the plugin, and internally use the plugin API directly. So the "minimum server version" comments on the helpers are in fact computable as the latest minimum server version on any API call made by the helpers.
Implement a reflective checker that examines the helper methods exposed on the Helpers interface, and their corresponding implementation in HelpersImpl, and determines if the commented minimum server version is correct based on what API methods the helpers call through.
Note that there may sometimes be cases where behaviour was "fixed" in a newer version, and the helper intentionally has a higher minimum. Thus, the tool should not fail if the minimum server version is higher than it need be: just emit a warning instead. But it's absolutely an error for a helper marked for vN to be relying on an API method that was only implemented in, for example, vN-1.
Build this into a plugin/checker package, and run the tool as part of the overall server build to ensure the helpers are always accurately commented.
Note that reflection in general is a tricky subject, and this issue should probably be tagged as 4: Very Hard. It is not recommended for anyone new to Go or who doesn’t have a somewhat working knowledge of Go reflection internals. Do not implement this using grep or similar strategies.