Skip to content

Commit f30842f

Browse files
committed
feat(xml,import): add error for backwards incompatibility
Signed-off-by: David Wallace <[email protected]>
1 parent 4e83f0b commit f30842f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: rdmo/core/xml.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,22 @@ def validate_and_get_xml_version_from_root(root: xmlElement) -> Tuple[Optional[V
7272
# Fallback to validate the legacy 'version' field
7373
try:
7474
xml_version = parse(unparsed_root_version)
75-
return xml_version, []
75+
7676
except ValueError:
7777
logger.info('Import failed: Invalid "version" format in XML (%s)', unparsed_root_version)
7878
errors = [_('The "version" attribute in this RDMO XML file is not a valid version.')]
7979
return None, errors
8080

81+
# RDMO 1.x can not import XMLs from RDMO 2.x
82+
if rdmo_version < parse('2.0.0') and xml_version >= parse('2.0.0'):
83+
logger.info('Import failed: Backwards compatibility is not supported for RDMO versions < 2.0.0')
84+
errors = [
85+
_('This RDMO XML file was created with a newer version of RDMO and cannot be imported.'),
86+
_('Backwards compatibility is not supported for RDMO versions lower than 2.0.0.')
87+
]
88+
return None, errors
89+
90+
return xml_version, []
8191

8292
def validate_legacy_elements(elements: dict, root_version: Version) -> list:
8393

0 commit comments

Comments
 (0)