Invalid instrument_session return 500 error
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 70/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- authentication, backend
Hướng nghiên cứu
Traceback trỏ đến require_submit_task trong src/blueapi/service/authorization.py, đoạn này ném một ValueError("Invalid instrument session") trần bên trong dependency submit_permission, nên nó thoát ra thành 500. Hãy đọc tệp đó cùng với phần xử lý ngoại lệ quanh src/blueapi/service/main.py để xem các lỗi miền khác trở thành phản hồi HTTP như thế nào, rồi ánh xạ lỗi này sang 401 hoặc 403. Tái hiện bằng uv run blueapi controller run --bg sleep -i non-visit và thêm hoặc mở rộng một test trong mô-đun test service/authorization để khẳng định mã trạng thái; xong nghĩa là client nhận 401/403 thay vì 500.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Attempting to run a plan with an invalid instrument session (malformed rather than not current) raises an internal server error
Steps to reproduce
- Start server with
just - Run a plan
uv run blueapi controller run --bg sleep -i non-visit
Logs and tracebacks
Server logs/traceback
2026-11-23 17:02:32,245 INFO blueapi.service.authorization Checking permissions to run task
2026-11-23 17:02:32,253 ERROR uvicorn.error Exception in ASGI application
Traceback (most recent call last):
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/httptools_impl.py", line 422, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.scope, self.receive, self.send
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 63, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/applications.py", line 1199, in __call__
await self._native_telemetry(
...<5 lines>...
)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/telemetry/_asgi.py", line 274, in __call__
await app(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/applications.py", line 96, in __call__
await self.middleware_stack(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/opentelemetry/instrumentation/asgi/__init__.py", line 779, in __call__
await self.app(scope, otel_receive, otel_send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/opentelemetry/instrumentation/fastapi/__init__.py", line 360, in __call__
await self.app(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/telemetry/_asgi.py", line 151, in __call__
await self.app(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 203, in __call__
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/src/blueapi/service/main.py", line 766, in log_request_details
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 179, in call_next
raise app_exc from app_exc.__cause__ or app_exc.__context__
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/dls/athena/blueapi/src/blueapi/service/middleware.py", line 134, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/src/blueapi/service/middleware.py", line 39, in __call__
return await self.app(scope, receive, local_send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/src/blueapi/service/middleware.py", line 64, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/routing.py", line 683, in __call__
await self.middleware_stack(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 2811, in app
await route.handle(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 1839, in handle
await self.original_router.handle(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 2894, in handle
await included_router._handle_selected(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 1865, in _handle_selected
await original_route.handle(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 1328, in handle
await effective_context.app(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 166, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 152, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 511, in app
solved_result = await solve_dependencies(
^^^^^^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
)
^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/fastapi/dependencies/utils.py", line 731, in solve_dependencies
solved = await call(**solved_result.values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/src/blueapi/service/authorization.py", line 135, in submit_permission
await opa.can_submit_task(task_request)
File "/dls/athena/blueapi/src/blueapi/service/authorization.py", line 94, in can_submit_task
await self.client.require_submit_task(task.instrument_session, self.token)
File "/dls/athena/blueapi/src/blueapi/service/authorization.py", line 66, in require_submit_task
raise ValueError("Invalid instrument session")
ValueError: Invalid instrument session
Client traceback
Traceback (most recent call last):
File "/dls/athena/blueapi/.venv/bin/blueapi", line 10, in <module>
sys.exit(main())
~~~~^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/core.py", line 1631, in __call__
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/core.py", line 1552, in main
rv = self.invoke(ctx)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/core.py", line 2032, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/core.py", line 2032, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/core.py", line 1415, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/core.py", line 910, in invoke
return callback(*args, **kwargs)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/click/decorators.py", line 46, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/dls/athena/blueapi/src/blueapi/cli/cli.py", line 281, in wrapper
return func(*args, **kwargs)
File "/dls/athena/blueapi/src/blueapi/cli/cli.py", line 462, in run_plan
server_task = client.create_and_start_task(task)
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/observability_utils/tracing/decorators.py", line 151, in wrapper
return func(*args, **kwargs)
File "/dls/athena/blueapi/src/blueapi/client/client.py", line 438, in create_and_start_task
response = self._rest.create_task(task)
File "/dls/athena/blueapi/src/blueapi/client/rest.py", line 257, in create_task
return self._request_v1(
~~~~~~~~~~~~~~~~^
"/tasks",
^^^^^^^^^
...<3 lines>...
data=task.model_dump(mode="json", fallback=_task_model_fallback),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/dls/athena/blueapi/.venv/lib/python3.13/site-packages/observability_utils/tracing/decorators.py", line 151, in wrapper
return func(*args, **kwargs)
File "/dls/athena/blueapi/src/blueapi/client/rest.py", line 338, in _request_and_deserialize
raise exception
blueapi.client.rest.BlueskyRequestError: (500, 'Internal Server Error')
blueapi version
1.22.0-29-g74b512fc5
Where are you running blueapi?
Local or developer machine
Impact on operations
None
Acceptance criteria
- Server returns either 401 or 403
- Ngôn ngữ chính
- Python
- Star
- 14
- Fork
- 15
- Merge trung bình
- 3 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DiamondLightSource/blueapi
-
support: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DiamondLightSource/blueapi#1772 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
deployment dev-environment
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DiamondLightSource/blueapi#1623 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Cannot Install SoftiocĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DiamondLightSource/blueapi#1605 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
DiamondLightSource/blueapi#1494 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
DiamondLightSource/blueapi#1819 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của DiamondLightSource/blueapi
Issue tương tự
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
trezor/trezor-user-env#421 ·
-
Support new version of pythonĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tangentcode/tangentswarm#167 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày