dstandish opened a new issue, #48769:
URL: https://github.com/apache/airflow/issues/48769

   ### Body
   
   If we upgrade, but do not reserialize or run dag processor, then we will get 
key error
   
   ```
   INFO:     127.0.0.1:54222 - "GET 
/api/v2/dags/xcom/dagRuns/~/taskInstances?run_after_gte=2025-04-02T21%3A21%3A10.610Z&run_after_lte=2025-04-03T21%3A21%3A10.610Z&state=failed
 HTTP/1.1" 500 Internal Server Error
   ERROR:    Exception in ASGI application
     + Exception Group Traceback (most recent call last):
     |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_utils.py",
 line 76, in collapse_excgroups
     |     yield
     |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 182, in __call__
     |     recv_stream.close()
     |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
 line 767, in __aexit__
     |     raise BaseExceptionGroup(
     | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 
sub-exception)
     +-+---------------- 1 ----------------
       | Traceback (most recent call last):
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py",
 line 409, in run_asgi
       |     result = await app(  # type: ignore[func-returns-value]
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/fastapi/applications.py",
 line 1054, in __call__
       |     await super().__call__(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/applications.py",
 line 112, in __call__
       |     await self.middleware_stack(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/errors.py",
 line 187, in __call__
       |     raise exc
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/errors.py",
 line 165, in __call__
       |     await self.app(scope, receive, _send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/gzip.py",
 line 20, in __call__
       |     await responder(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/gzip.py",
 line 39, in __call__
       |     await self.app(scope, receive, self.send_with_gzip)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/cors.py",
 line 85, in __call__
       |     await self.app(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 182, in __call__
       |     recv_stream.close()
       |   File 
"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py",
 line 135, in __exit__
       |     self.gen.throw(type, value, traceback)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_utils.py",
 line 82, in collapse_excgroups
       |     raise exc
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 179, in __call__
       |     response = await self.dispatch_func(request, call_next)
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/api_fastapi/core_api/middleware.py",
 line 28, in dispatch
       |     response = await call_next(request)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 154, in call_next
       |     raise app_exc
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 141, in coro
       |     await self.app(scope, receive_or_disconnect, send_no_error)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py",
 line 62, in __call__
       |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, 
send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       |     raise exc
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       |     await app(scope, receive, sender)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 715, in __call__
       |     await self.middleware_stack(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 735, in app
       |     await route.handle(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 288, in handle
       |     await self.app(scope, receive, send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 76, in app
       |     await wrap_app_handling_exceptions(app, request)(scope, receive, 
send)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       |     raise exc
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       |     await app(scope, receive, sender)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 73, in app
       |     response = await f(request)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/fastapi/routing.py",
 line 301, in app
       |     raw_response = await run_endpoint_function(
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/fastapi/routing.py",
 line 214, in run_endpoint_function
       |     return await run_in_threadpool(dependant.call, **values)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/concurrency.py",
 line 37, in run_in_threadpool
       |     return await anyio.to_thread.run_sync(func)
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/to_thread.py",
 line 56, in run_sync
       |     return await get_async_backend().run_sync_in_worker_thread(
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
 line 2461, in run_sync_in_worker_thread
       |     return await future
       |   File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
 line 962, in run
       |     result = context.run(func, *args)
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py",
 line 431, in get_task_instances
       |     dag = request.app.state.dag_bag.get_dag(dag_id)
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/utils/session.py", line 
102, in wrapper
       |     return func(*args, session=session, **kwargs)
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/models/dagbag.py", line 
199, in get_dag
       |     self._add_dag_from_db(dag_id=dag_id, session=session)
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/models/dagbag.py", line 
277, in _add_dag_from_db
       |     dag = row.dag
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/models/serialized_dag.py",
 line 529, in dag
       |     return SerializedDAG.from_dict(data)
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/serialization/serialized_objects.py",
 line 1790, in from_dict
       |     return cls.deserialize_dag(serialized_obj["dag"])
       |   File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/serialization/serialized_objects.py",
 line 1697, in deserialize_dag
       |     dag = SerializedDAG(dag_id=encoded_dag["dag_id"], schedule=None)
       | KeyError: 'dag_id'
       +------------------------------------
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py",
 line 409, in run_asgi
       result = await app(  # type: ignore[func-returns-value]
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/fastapi/applications.py",
 line 1054, in __call__
       await super().__call__(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/applications.py",
 line 112, in __call__
       await self.middleware_stack(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/errors.py",
 line 187, in __call__
       raise exc
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/errors.py",
 line 165, in __call__
       await self.app(scope, receive, _send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/gzip.py",
 line 20, in __call__
       await responder(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/gzip.py",
 line 39, in __call__
       await self.app(scope, receive, self.send_with_gzip)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/cors.py",
 line 85, in __call__
       await self.app(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 182, in __call__
       recv_stream.close()
     File 
"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py",
 line 135, in __exit__
       self.gen.throw(type, value, traceback)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_utils.py",
 line 82, in collapse_excgroups
       raise exc
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 179, in __call__
       response = await self.dispatch_func(request, call_next)
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/api_fastapi/core_api/middleware.py",
 line 28, in dispatch
       response = await call_next(request)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 154, in call_next
       raise app_exc
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/base.py",
 line 141, in coro
       await self.app(scope, receive_or_disconnect, send_no_error)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py",
 line 62, in __call__
       await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       raise exc
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       await app(scope, receive, sender)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 715, in __call__
       await self.middleware_stack(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 735, in app
       await route.handle(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 288, in handle
       await self.app(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 76, in app
       await wrap_app_handling_exceptions(app, request)(scope, receive, send)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 53, in wrapped_app
       raise exc
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py",
 line 42, in wrapped_app
       await app(scope, receive, sender)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/routing.py",
 line 73, in app
       response = await f(request)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/fastapi/routing.py",
 line 301, in app
       raw_response = await run_endpoint_function(
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/fastapi/routing.py",
 line 214, in run_endpoint_function
       return await run_in_threadpool(dependant.call, **values)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/starlette/concurrency.py",
 line 37, in run_in_threadpool
       return await anyio.to_thread.run_sync(func)
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/to_thread.py",
 line 56, in run_sync
       return await get_async_backend().run_sync_in_worker_thread(
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
 line 2461, in run_sync_in_worker_thread
       return await future
     File 
"/Users/dstandish/code/airflow/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
 line 962, in run
       result = context.run(func, *args)
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py",
 line 431, in get_task_instances
       dag = request.app.state.dag_bag.get_dag(dag_id)
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/utils/session.py", line 
102, in wrapper
       return func(*args, session=session, **kwargs)
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/models/dagbag.py", line 
199, in get_dag
       self._add_dag_from_db(dag_id=dag_id, session=session)
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/models/dagbag.py", line 
277, in _add_dag_from_db
       dag = row.dag
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/models/serialized_dag.py",
 line 529, in dag
       return SerializedDAG.from_dict(data)
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/serialization/serialized_objects.py",
 line 1790, in from_dict
       return cls.deserialize_dag(serialized_obj["dag"])
     File 
"/Users/dstandish/code/airflow/airflow-core/src/airflow/serialization/serialized_objects.py",
 line 1697, in deserialize_dag
       dag = SerializedDAG(dag_id=encoded_dag["dag_id"], schedule=None)
   KeyError: 'dag_id'
   ```
   
   cc @ashb @kaxil @vatsrahul1001 @phanikumv 
   
   ### Committer
   
   - [x] I acknowledge that I am a maintainer/committer of the Apache Airflow 
project.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to