diff options
author | Huayu Ouyang <huayu.ouyang@mongodb.com> | 2021-11-16 20:20:04 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-22 22:17:16 +0000 |
commit | e818cd876ed3b492517400a3da3f687fbe13d8aa (patch) | |
tree | 949699278df951eadbc45da35c2ee7da424e7ff0 /buildscripts/idl/idl_compatibility_errors.py | |
parent | 337e43030afb6de83a2e3ed25575ec8874a70d20 (diff) | |
download | mongo-e818cd876ed3b492517400a3da3f687fbe13d8aa.tar.gz |
SERVER-60814 Require 'unstable' field to avoid accidental additions to the stable API
Diffstat (limited to 'buildscripts/idl/idl_compatibility_errors.py')
-rw-r--r-- | buildscripts/idl/idl_compatibility_errors.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/buildscripts/idl/idl_compatibility_errors.py b/buildscripts/idl/idl_compatibility_errors.py index 5ae62ad9891..13eac6a9318 100644 --- a/buildscripts/idl/idl_compatibility_errors.py +++ b/buildscripts/idl/idl_compatibility_errors.py @@ -118,6 +118,9 @@ ERROR_ID_REPLY_FIELD_SERIALIZER_NOT_EQUAL = "ID0073" ERROR_ID_COMMAND_DESERIALIZER_NOT_EQUAL = "ID0074" ERROR_ID_COMMAND_PARAMETER_DESERIALIZER_NOT_EQUAL = "ID0075" ERROR_ID_REPLY_FIELD_DESERIALIZER_NOT_EQUAL = "ID0076" +ERROR_ID_NEW_REPLY_FIELD_REQUIRES_UNSTABLE = "ID0077" +ERROR_ID_NEW_PARAMETER_REQUIRES_UNSTABLE = "ID0078" +ERROR_ID_NEW_COMMAND_TYPE_FIELD_REQUIRES_UNSTABLE = "ID0079" class IDLCompatibilityCheckerError(Exception): @@ -974,6 +977,27 @@ class IDLCompatibilityContext(object): ("The generic reply field '%s' was removed from the new generic_argument.idl file") % (field_name), file) + def add_new_reply_field_requires_unstable_error(self, command_name: str, field_name: str, + file: str) -> None: + """Add an error that a new reply field requires the 'unstable' field.""" + self._add_error(ERROR_ID_NEW_REPLY_FIELD_REQUIRES_UNSTABLE, command_name, ( + "'%s' has new reply field '%s' that requires specifying a value for the 'unstable' field" + ) % (command_name, field_name), file) + + def add_new_param_or_command_type_field_requires_unstable_error( + self, command_name: str, field_name: str, file: str, + is_command_parameter: bool) -> None: + # pylint: disable=invalid-name + """Add an error that a new param or command type field requires the 'unstable' field.""" + if is_command_parameter: + self._add_error(ERROR_ID_NEW_PARAMETER_REQUIRES_UNSTABLE, command_name, ( + "'%s' has new parameter '%s' that requires specifying a value for the 'unstable' field" + ) % (command_name, field_name), file) + else: + self._add_error(ERROR_ID_NEW_COMMAND_TYPE_FIELD_REQUIRES_UNSTABLE, command_name, ( + "'%s' has new command type field '%s' that requires specifying a value for the 'unstable' field" + ) % (command_name, field_name), file) + def _assert_unique_error_messages() -> None: """Assert that error codes are unique.""" |