Przeglądaj źródła

Camera: the #3515 shields pass the type check

- basedpyright treats the shielded CancelScope as able to swallow an
  exception: the light settings could be unbound and the stream
  re-check could end without an answer
- The settings start as None (off, default delay); the re-check ends
  with "not allowed" after the scope, which nothing reaches
maziggy 9 godzin temu
rodzic
commit
5297f53d2b
2 zmienionych plików z 4 dodań i 0 usunięć
  1. 3 0
      backend/app/core/auth.py
  2. 1 0
      backend/app/services/camera_light.py

+ 3 - 0
backend/app/core/auth.py

@@ -1284,6 +1284,9 @@ async def stream_opener_still_allowed(opener: StreamOpener, printer_id: int) ->
                 else:
                     return False
                 return scope.allows(printer_id)
+        # Unreachable: nothing cancels this scope itself, so it never swallows
+        # the return above. Never an answer of "allowed" if it ever did.
+        return False
     except Exception:  # SEC-AUTH-EXC: logged and re-raised, never an answer
         logger.warning("Camera stream re-check failed", exc_info=True)
         raise

+ 1 - 0
backend/app/services/camera_light.py

@@ -61,6 +61,7 @@ async def _read_settings() -> tuple[str, float]:
     # Shielded (#3515): a viewer leaving cancels the stream, and a read
     # cancelled halfway costs its pooled connection. The two short reads and
     # the session's close run to the end first.
+    mode = delay = None
     with anyio.CancelScope(shield=True):
         async with database.async_session() as db:
             mode = await get_setting(db, "camera_light_mode")