I had to think about your question for a while.
Semver - and versioning in general - is a set of rules about intentions, even though we have a lot of practice around it as a set of rules about software. One of the key intentions expressed through semver is that if two releases of a piece of software share a major version number, then other software that behaves correctly when using the earlier release, which uses that software in its intended ways, will continue to behave correctly when using the later release.
Which brings me to this section of your example.
As documented, one thing it might be reasonable for a downstream developer to rely on is that the presence of an error means only and exactly that the ciphertext is authentic. I might argue as a matter of style that the code in question should examine the DecryptError
value to verify that, but unless DecryptError
is #[non_exhaustive]
, it would be valid to assume that the only possible value it has is DecryptError::InauthenticCiphertext
(however it's named).
This change is not compatible with that assumption. Code written - in questionable style - that makes the assumption that the error can only mean one thing will not behave correctly when it encounters an error that means one of the two new things it can now mean.
This isn't just an abstract concern. These kinds of assumptions can propagate outwards, potentially so far as to tell the end user what the error "is" based on that assumption. An error message that shows an "invalid ciphertext" message may now be incorrect if it is triggered by a programming error that leads to incorrect lengths, for example, and the user may not have the tools to troubleshoot it.
I don't think this necessarily requires a major version change, but it could. A lot depends on whether the hypothetical client code I described above is or is not using this library "as intended" - or, put another way, whether this is a kind of backwards compatibility the authors intend to support. A lot could be inferred from the presence or absence of a #[non_exhaustive]
marker on the error type, for example, as that would communicate the intentions of the developers with respect to adding values to the error enumeration later on.
However, I would err on the side of caution in most cases, and reserve this change for the next major version, unless there is a strong user community request for it in the current version and little risk of the technical compatibility risk turning into an actual problem.