Skip to content

[BUG] Inconsistent handling of malformed input across CLI commands #5

@T-artist-cyber

Description

@T-artist-cyber

"inspect", "validate", and "replay" handle the same malformed input inconsistently.

When processing samples/malformed_frame.sgf, the inspect command succeeds and returns stream metadata, while validate and replay terminate with an uncaught ParseError traceback.

This creates inconsistent malformed-input handling across CLI commands.

Reproduction Steps

  1. Clone the repository
  2. Install the package:

bash
python -m pip install -e .

  1. Run:

python -m sigflow inspect samples\malformed_frame.sgf

  1. Run:

python -m sigflow validate samples\malformed_frame.sgf

  1. Run:

python -m sigflow replay samples\malformed_frame.sgf

Expected Behavior

Malformed input handling should be consistent across CLI commands.

Commands should either:

gracefully return diagnostics/errors, or

consistently reject malformed input without uncaught exceptions.

validate and replay should not terminate with a full traceback if inspect can safely process the same malformed stream.

Actual Behavior

inspect succeeds and prints stream information.

Example:

path=samples\malformed_frame.sgf
bytes=28
prefix=4241442101000000002a000000000000000100000015d1b0e4e27365

However, validate and replay terminate with:

sigflow.core.exceptions.ParseError: truncated input

Root Cause Analysis

The inconsistency occurs because CLI commands handle parsing errors differently in the execution pipeline.

The inspect command catches or suppresses ParseError during stream metadata extraction, allowing partial parsing of malformed frames.

However, validate and replay directly invoke the parser through sigflow/core/engine.py without a unified exception-handling layer, causing ParseError to propagate uncaught from sigflow/parsers/base.py and terminate execution.

This indicates missing centralized error handling for parser exceptions across CLI command implementations.

Impact

This results in an inconsistent developer experience when working with malformed or partially corrupted .sgf files.

Users cannot predict whether a command will gracefully handle invalid input or crash with a traceback.

In debugging workflows, this makes validate and replay unreliable for inspecting real-world corrupted streams, while inspect behaves more resiliently.

This inconsistency reduces trust in CLI stability and complicates error-handling expectations across tools.

Environment

Python version: 3.13.5

sigflow version or commit: latest repository clone

Operating system: Windows

**Additional **

The traceback propagates through:

sigflow/cli/commands.py

sigflow/core/engine.py

sigflow/parsers/protocol.py

sigflow/parsers/tlv.py

sigflow/parsers/base.py

The parser raises:

ParseError("truncated input", offset=offset)

but this exception is not handled consistently across CLI commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions