Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: improve error message when generating an artifact for an object that doesn't inherit from the CoreArtifactTarget generic #5501

Open
wvandeun opened this issue Jan 17, 2025 · 0 comments
Labels
group/backend Issue related to the backend (API Server, Git Agent) type/bug Something isn't working as expected

Comments

@wvandeun
Copy link
Contributor

wvandeun commented Jan 17, 2025

Component

API Server / GraphQL

Infrahub version

1.1.3

Current Behavior

You get the following error message in the artifact generation task, when the object's schemanode does not inherit from the CoreArtifactTarget generic.

Task run failed with exception: GraphQLError('An error occurred while executing the GraphQL Query \nmutation {\n CoreArtifactCreate(\n data: {\n name: {\n value: "Interface_configuration"\n }\n status: {\n value: "Pending"\n }\n content_type: {\n value: "text/plain"\n }\n object: {\n id: "181b7215-5e4f-7ce0-3037-c51e36c219b7"\n }\n definition: {\n id: "181b720a-caa8-8ef9-303e-c51ce5477c7a"\n }\n }\n ){\n ok\n object {\n id\n }\n }\n}\n, [{\'message\': \'NetworkDevice - 181b7215-5e4f-7ce0-3037-c51e36c219b7 cannot be added to relationship, must be of type: [] at object\', \'locations\': [{\'line\': 3, \'column\': 5}], \'path\': [\'CoreArtifactCreate\']}]') - Retries are exhausted Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/prefect/task_engine.py", line 1268, in run_context yield self File "/usr/local/lib/python3.12/site-packages/prefect/task_engine.py", line 1345, in run_task_async await engine.call_task_fn(txn) File "/usr/local/lib/python3.12/site-packages/prefect/task_engine.py", line 1291, in call_task_fn result = await call_with_parameters(self.task.fn, parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/source/backend/infrahub/tasks/artifact.py", line 44, in define_artifact await artifact.save() File "/source/python_sdk/infrahub_sdk/node.py", line 1152, in save await self.create(allow_upsert=allow_upsert, timeout=timeout) File "/source/python_sdk/infrahub_sdk/node.py", line 1401, in create response = await self._client.execute_graphql( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/source/python_sdk/infrahub_sdk/client.py", line 907, in execute_graphql raise GraphQLError(errors=response["errors"], query=query, variables=variables) infrahub_sdk.exceptions.GraphQLError: An error occurred while executing the GraphQL Query mutation { CoreArtifactCreate( data: { name: { value: "Interface_configuration" } status: { value: "Pending" } content_type: { value: "text/plain" } object: { id: "181b7215-5e4f-7ce0-3037-c51e36c219b7" } definition: { id: "181b720a-caa8-8ef9-303e-c51ce5477c7a" } } ){ ok object { id } } } , [{'message': 'NetworkDevice - 181b7215-5e4f-7ce0-3037-c51e36c219b7 cannot be added to relationship, must be of type: [] at object', 'locations': [{'line': 3, 'column': 5}], 'path': ['CoreArtifactCreate']}]

Expected Behavior

The error message should clearly explain what is wrong.

Steps to Reproduce

  • Start instance of Infrahub
  • Create a group AllDevices
  • import https://github.com/wvandeun/ext-repo-public.git as a read-only repository
  • Create a manufacturer
  • Create a device type
  • Create a device
  • Create an interface for the device
  • Add the device to the AllDevices group
  • Generate an artifact from the interface_configuration artifact definition
  • Go to the tasks list view
  • You will see that the artifact generation task has failed with the above error message

Additional Information

No response

@wvandeun wvandeun added type/bug Something isn't working as expected group/backend Issue related to the backend (API Server, Git Agent) labels Jan 17, 2025
@wvandeun wvandeun changed the title bug: cannot generate an artifact for an object if it doesn't inherit from CoreArtifactTarget generic bug: improve error message when generating an artifact for an object that doesn't inherit from the CoreArtifactTarget generic Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent) type/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

1 participant