ruvnet/RuView · error · ValueError

Unknown stream: {stream_id}

Error message

Unknown stream: {stream_id}

What it means

ValueError raised by start_pose_visualization_stream when the given stream_id is not a key in the manager's in-memory active_streams dict. Only streams created through the create-stream flow (which stores rtmp_url, stream_key, status='created') are known, and the registry lives only in process memory. Any ID that was never created, was created elsewhere, or was lost to a restart is 'unknown'.

Source

Thrown at plans/phase2-architecture/api-architecture.md:1418

                    stream_data = await response.json()
                    stream_id = stream_data['id']
                    rtmp_url = stream_data['ingests']['rtmp']['url']
                    stream_key = stream_data['ingests']['rtmp']['stream_key']
                    
                    self.active_streams[stream_id] = {
                        'rtmp_url': rtmp_url,
                        'stream_key': stream_key,
                        'status': 'created'
                    }
                    
                    return stream_id, f"{rtmp_url}/{stream_key}"
                else:
                    raise Exception(f"Failed to create stream: {response.status}")
    
    async def start_pose_visualization_stream(self, stream_id: str):
        """Start streaming pose visualization"""
        if stream_id not in self.active_streams:
            raise ValueError(f"Unknown stream: {stream_id}")
        
        stream_info = self.active_streams[stream_id]
        rtmp_endpoint = f"{stream_info['rtmp_url']}/{stream_info['stream_key']}"
        
        # Start FFmpeg process for streaming
        ffmpeg_cmd = [
            'ffmpeg',
            '-f', 'rawvideo',
            '-pixel_format', 'bgr24',
            '-video_size', '1280x720',
            '-framerate', '30',
            '-i', '-',  # Input from stdin
            '-c:v', 'libx264',
            '-preset', 'veryfast',
            '-maxrate', '3000k',
            '-bufsize', '6000k',
            '-pix_fmt', 'yuv420p',
            '-g', '60',

View on GitHub (pinned to 4685618388)

Solutions

  1. Create the stream first via the create endpoint and pass the returned stream_id to start_pose_visualization_stream unchanged
  2. If the server restarted, re-create the stream to get a fresh ID before starting it
  3. For multi-worker deployments, use sticky sessions or back active_streams with shared storage (e.g. Redis) instead of a plain dict
  4. Catch the ValueError at the API layer and map it to a 404 with the offending stream_id so clients can recover

Example fix

# before
await stream_manager.start_pose_visualization_stream(requested_stream_id)  # ValueError if unknown

# after
if requested_stream_id not in stream_manager.active_streams:
    requested_stream_id, url = await stream_manager.create_pose_visualization_stream()
await stream_manager.start_pose_visualization_stream(requested_stream_id)
Defensive patterns

Strategy: validation

Validate before calling

if stream_id not in stream_manager.active_streams:
    raise KeyError(f'refusing to start: {stream_id} not in active_streams; create it first')
await stream_manager.start_pose_visualization_stream(stream_id)

Type guard

def is_known_stream(manager, stream_id: str) -> bool:
    return stream_id in manager.active_streams

Try / catch

try:
    await manager.start_pose_visualization_stream(stream_id)
except ValueError as e:
    if 'Unknown stream' in str(e):
        stream_id, _ = await manager.create_pose_visualization_stream()
        await manager.start_pose_visualization_stream(stream_id)
    else:
        raise

Prevention

When it happens

Trigger: Calling start_pose_visualization_stream(stream_id) with an ID that (a) was never returned by create_stream, (b) came from a different server instance/worker (dict is process-local), (c) existed before a server restart wiped active_streams, or (d) was already removed by cleanup/stop logic.

Common situations: Load-balanced deployments where create hits worker A and start hits worker B; dev/test scripts passing hardcoded or fabricated stream IDs; server restarted between create and start; typo or truncated ID copied from logs.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/70abc370c4727806. Report an issue: GitHub.