Skip to content

create_flow_run_from_deployment fails with AttrubuteError #18707

@922tech

Description

@922tech

Bug summary

When I try to call this async function I get error code(500) from the server logs

async def main(taskCount=8):
from prefect.deployments import run_deployment

await run_deployment(
    name="my-flow/test_flow",flow_run_name="dddddd",
    parameters={"task_id": 132, "username": "21sdf3", "password": "134sdf5"},
    work_queue_name='test-pool', poll_interval=1
)
12:08:05.776 | ERROR   | prefect.server - Encountered exception in request:
Traceback (most recent call last):
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 20, in __call__
    await responder(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 39, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/prefect/server/utilities/server.py", line 50, in handle_response_scoped_depends
    response = await default_handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/prefect/server/api/deployments.py", line 792, in create_flow_run_from_deployment
    work_pool_name=deployment.work_queue.work_pool.name,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'work_pool'
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 460, in handle
    await self.app(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 20, in __call__
    await responder(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 39, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/prefect/server/utilities/server.py", line 50, in handle_response_scoped_depends
    response = await default_handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/projects/venvs/venv3.11/lib/python3.11/site-packages/prefect/server/api/deployments.py", line 792, in create_flow_run_from_deployment
    work_pool_name=deployment.work_queue.work_pool.name,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'work_pool'

Version info

Version: 3.4.11
Platform: Ubuntu 23.10

prefect.toml:


[core]
telemetry = false  # disables telemetry

[work_queues]
type = "redis"  # use Redis for work queues
redis_connection_url = "redis://localhost:6379/0"  # your Redis connection string
[server]
[server.database]
connection_url = "postgresql+asyncpg://postgres:arka@localhost:5434/prefect"
timeout = 600

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions