|
10 | 10 | from infrahub.core.convert_object_type.repository_conversion import convert_repository_type |
11 | 11 | from infrahub.core.convert_object_type.schema_mapping import get_schema_mapping |
12 | 12 | from infrahub.core.manager import NodeManager |
| 13 | +from infrahub.exceptions import ValidationError |
13 | 14 | from infrahub.repositories.create_repository import RepositoryFinalizer |
14 | 15 |
|
15 | 16 | if TYPE_CHECKING: |
| 17 | + from infrahub.core.attribute import BaseAttribute |
16 | 18 | from infrahub.graphql.initialization import GraphqlContext |
17 | 19 |
|
18 | 20 |
|
@@ -49,14 +51,22 @@ async def mutate( |
49 | 51 |
|
50 | 52 | fields_mapping: dict[str, ConversionFieldInput] = {} |
51 | 53 | if not isinstance(data.fields_mapping, dict): |
52 | | - raise ValueError(f"Expected `fields_mapping` to be a `dict`, got {type(data.fields_mapping)}") |
| 54 | + raise ValidationError( |
| 55 | + input_value=f"Expected `fields_mapping` to be a `dict`, got {type(data.fields_mapping)}" |
| 56 | + ) |
53 | 57 |
|
54 | 58 | for field_name, input_for_dest_field_str in data.fields_mapping.items(): |
55 | 59 | fields_mapping[field_name] = ConversionFieldInput(**input_for_dest_field_str) |
56 | 60 |
|
57 | 61 | node_to_convert = await NodeManager.get_one( |
58 | 62 | id=str(data.node_id), db=graphql_context.db, branch=graphql_context.branch |
59 | 63 | ) |
| 64 | + for attribute_name in source_schema.attribute_names: |
| 65 | + attribute: BaseAttribute = getattr(node_to_convert, attribute_name) |
| 66 | + if attribute.is_from_profile: |
| 67 | + raise ValidationError( |
| 68 | + input_value=f"The attribute '{attribute_name}' is from a profile, converting objects that use profiles is not yet supported." |
| 69 | + ) |
60 | 70 |
|
61 | 71 | # Complete fields mapping with auto-mapping. |
62 | 72 | mapping = get_schema_mapping(source_schema=source_schema, target_schema=target_schema) |
|
0 commit comments