Skip to content

fix: singleresult dataclass fields default to none but typed as non-optional — will crash on attribute access #287

Description

Description

The SingleResult dataclass declares example: Example and result: RunResult but defaults both to None. The # type: ignore[assignment] silences the type checker but does not fix the runtime problem: any code that constructs SingleResult() without explicitly setting both fields and then accesses sr.example.name or sr.result.exit_code will crash with AttributeError: 'NoneType' object has no attribute 'name'. The sibling class RunResult demonstrates the correct pattern — every field has a concrete default. Example requires three non-defaulted args (name, path, cwd), so the author punted with None. Callers have no type-level signal that these fields can be absent.

Severity: high
File: sdk/python/validation/models.py

Expected Behavior

The code should handle this case properly to avoid unexpected errors or degraded quality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions