You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you load a schema using the REST API endpoint /api/schema/load, that deletes a node from the schema, to which another node in the schema still has a relationship then you will get a HTTP 500 - internal server error response.
In the logs of the api server, we can find the following message, indicating we are catching the issue properly
{"event": "Exception in ASGI application
", "timestamp": "2024-11-11T12:46:40.047476Z", "logger": "uvicorn.error", "level": "error", "exception": "Traceback (most recent call last):
File \"/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 401, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py\", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/fastapi/applications.py\", line 1054, in __call__
await super().__call__(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/applications.py\", line 113, in __call__
await self.middleware_stack(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py\", line 187, in __call__
raise exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py\", line 165, in __call__
await self.app(scope, receive, _send)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/gzip.py\", line 20, in __call__
await responder(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/gzip.py\", line 39, in __call__
await self.app(scope, receive, self.send_with_gzip)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py\", line 85, in __call__
await self.app(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette_exporter/middleware.py\", line 499, in __call__
raise exception
File \"/usr/local/lib/python3.12/site-packages/starlette_exporter/middleware.py\", line 405, in __call__
await self.app(scope, receive, wrapped_send)
File \"/usr/local/lib/python3.12/site-packages/asgi_correlation_id/middleware.py\", line 90, in __call__
await self.app(scope, receive, handle_outgoing_request)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 185, in __call__
with collapse_excgroups():
^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/contextlib.py\", line 158, in __exit__
self.gen.throw(value)
File \"/usr/local/lib/python3.12/site-packages/starlette/_utils.py\", line 82, in collapse_excgroups
raise exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 187, in __call__
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/source/backend/infrahub/server.py\", line 172, in add_telemetry_span_exception
return await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 163, in call_next
raise app_exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 185, in __call__
with collapse_excgroups():
^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/contextlib.py\", line 158, in __exit__
self.gen.throw(value)
File \"/usr/local/lib/python3.12/site-packages/starlette/_utils.py\", line 82, in collapse_excgroups
raise exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 187, in __call__
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/source/backend/infrahub/server.py\", line 161, in add_process_time_header
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 163, in call_next
raise app_exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 185, in __call__
with collapse_excgroups():
^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/contextlib.py\", line 158, in __exit__
self.gen.throw(value)
File \"/usr/local/lib/python3.12/site-packages/starlette/_utils.py\", line 82, in collapse_excgroups
raise exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 187, in __call__
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/source/backend/infrahub/server.py\", line 154, in logging_middleware
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 163, in call_next
raise app_exc
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py\", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File \"/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/asgi/__init__.py\", line 631, in __call__
await self.app(scope, otel_receive, otel_send)
File \"/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py\", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py\", line 62, in wrapped_app
raise exc
File \"/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py\", line 51, in wrapped_app
await app(scope, receive, sender)
File \"/usr/local/lib/python3.12/site-packages/starlette/routing.py\", line 715, in __call__
await self.middleware_stack(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/routing.py\", line 735, in app
await route.handle(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/routing.py\", line 288, in handle
await self.app(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/routing.py\", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File \"/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py\", line 62, in wrapped_app
raise exc
File \"/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py\", line 51, in wrapped_app
await app(scope, receive, sender)
File \"/usr/local/lib/python3.12/site-packages/starlette/routing.py\", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/fastapi/routing.py\", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/usr/local/lib/python3.12/site-packages/fastapi/routing.py\", line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/source/backend/infrahub/api/schema.py\", line 304, in load_schema
await registry.schema.update_schema_branch(
File \"/source/backend/infrahub/core/schema/manager.py\", line 172, in update_schema_branch
updated_schema = await self.load_schema_from_db(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/source/backend/infrahub/core/schema/manager.py\", line 672, in load_schema_from_db
schema.process(validate_schema=validate_schema)
File \"/source/backend/infrahub/core/schema/schema_branch.py\", line 445, in process
self.process_validate()
File \"/source/backend/infrahub/core/schema/schema_branch.py\", line 460, in process_validate
self.validate_kinds()
File \"/source/backend/infrahub/core/schema/schema_branch.py\", line 899, in validate_kinds
raise ValueError(
ValueError: TestingTestNode2: Relationship 'test_node_1' is referencing an invalid peer 'TestingTestNode1'"}
Expected Behavior
This is a problem with the schema that the user is trying to load. This should be detected by Infrahub and we should return a client error response with a precise reason for failure.
Component
API Server / GraphQL
Infrahub version
1.0.3
Current Behavior
When you load a schema using the REST API endpoint
/api/schema/load
, that deletes a node from the schema, to which another node in the schema still has a relationship then you will get a HTTP 500 - internal server error response.In the logs of the api server, we can find the following message, indicating we are catching the issue properly
Expected Behavior
This is a problem with the schema that the user is trying to load. This should be detected by Infrahub and we should return a client error response with a precise reason for failure.
Steps to Reproduce
Additional Information
No response
The text was updated successfully, but these errors were encountered: