Skip to content

validate_snippet.py: no-arg default scan crashes on non-XML/binary files in agent/sandbox/ #82

Description

@agentic-fm

Summary

agent/scripts/validate_snippet.py, when run with no path argument (its default mode, which scans agent/sandbox/), crashes with a UnicodeDecodeError if the sandbox contains any non-XML/binary file (e.g. a .png). It reads each file as UTF-8 without guarding against non-text content.

Reproduction

  1. Place any binary file in agent/sandbox/ (e.g. a .png screenshot).
  2. Run python3 agent/scripts/validate_snippet.py with no arguments.

Observed

File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

(0x89 is the PNG signature.)

Expected

The default scan should skip (or -- warn on) files it can't read as XML/UTF-8, and continue validating the real snippets, rather than aborting the whole run.

Notes

  • Pre-existing — reproduces on main today; not introduced by any open PR (surfaced while E2E-verifying feat(scripts): validate_snippet.py accepts multiple file paths #73, whose multi-path change is unrelated and works correctly).
  • Only bites when agent/sandbox/ holds real working files; a clean checkout has an empty sandbox, which is why it hasn't been noticed.
  • Low severity, self-contained. Good candidate for a newcomer: filter the default glob to *.xml and/or wrap the read in a try/except that skips undecodable files with a warning.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfirmedBug reproduced/confirmedgood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions