Skip to content

Normalize status_data.error to list[ErrorDetail] #11337

@rapsealk

Description

@rapsealk

Sub-issue of #679.

Goal

Eliminate the dual-shape status_data.error payload (single dict vs. {collection: [...]} for MultiAgentError) by always emitting a flat errors: list[ErrorDetail].

Background

Currently src/ai/backend/manager/exceptions.py:101-143 (convert_to_status_data) produces one of two incompatible shapes depending on whether the cause is a MultiAgentError. Consumers must shape-sniff at runtime — see src/ai/backend/manager/event_dispatcher/handlers/session.py:232-235:

if status_data["error"]["name"] == "MultiAgentError":
    errors = status_data["error"]["collection"]
else:
    errors = [status_data["error"]]

Scope

Backward-compatible rollout (so backend.ai-webui can migrate independently):

  1. Modify convert_to_status_data to return both:
    • The legacy error: ErrorDetail field (unchanged, for backward compat)
    • A new errors: list[ErrorDetail] field (always flat — single errors are a 1-element list, MultiAgentError is the flattened collection)
  2. Update the manager-internal consumer at event_dispatcher/handlers/session.py:232-235 to read errors first, fall back to shape-sniffing only if missing.
  3. Add deprecation note for the legacy error field; plan removal in a later release after backend.ai-webui migrates.

Non-goals

Acceptance criteria

  • convert_to_status_data always emits errors: list[ErrorDetail] in addition to legacy error.
  • event_dispatcher/handlers/session.py consumes errors first.
  • Tests cover: single error → 1-element list; MultiAgentError → flattened list; debug mode preserves traceback / agent_id per entry.
  • Pants quality gates pass.
  • PR description flags follow-up work for webui coordination.

JIRA Issue: BA-5865

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Story.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions