diff --git a/iib/web/models.py b/iib/web/models.py index c87414e12..50e6d28da 100644 --- a/iib/web/models.py +++ b/iib/web/models.py @@ -10,7 +10,6 @@ from flask import current_app, url_for from flask_login import UserMixin, current_user from flask_sqlalchemy.model import DefaultMeta -import ruamel.yaml import sqlalchemy from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.orm import joinedload, load_only, Mapped, validates @@ -46,17 +45,6 @@ FbcOperationRequestResponse, ) -yaml = ruamel.yaml.YAML() -# IMPORTANT: ruamel will introduce a line break if the yaml line is longer than yaml.width. -# Unfortunately, this causes issues for JSON values nested within a YAML file, e.g. -# metadata.annotations."alm-examples" in a CSV file. -# The default value is 80. Set it to a more forgiving higher number to avoid issues -yaml.width = 200 -# ruamel will also cause issues when normalizing a YAML object that contains -# a nested JSON object when it does not preserve quotes. Thus, it produces -# invalid YAML. Let's prevent this from happening at all. -yaml.preserve_quotes = True - class BaseEnum(Enum): """A base class for IIB enums.""" @@ -2336,9 +2324,9 @@ def from_json( # type: ignore[override] # noqa: F821 if not _deprecation_schema or not isinstance(_deprecation_schema, str): raise ValidationError('"deprecation_schema" should be a non-empty string') try: - yaml.load(_deprecation_schema) - except ruamel.yaml.YAMLError: - raise ValidationError('"deprecation_schema" string should be valid YAML') + json.loads(_deprecation_schema) + except ValueError: + raise ValidationError('"deprecation_schema" string should be valid JSON') # cast to more wider type, see _from_json method cls._from_json( diff --git a/tests/test_web/test_api_v1.py b/tests/test_web/test_api_v1.py index 6347e7b14..da7b01cd1 100644 --- a/tests/test_web/test_api_v1.py +++ b/tests/test_web/test_api_v1.py @@ -2875,9 +2875,9 @@ def test_fbc_operations( 'from_index': 'pull:spec', 'binary_image': 'binary:image', 'operator_package': 'my-package', - 'deprecation_schema': '{invalid_yaml', + 'deprecation_schema': '{{{invalid_json', }, - '"deprecation_schema" string should be valid YAML', + '"deprecation_schema" string should be valid JSON', ), ), )