Skip to content

fix(ai): run ids with a trailing newline fail validation #917

Description

@dan-petty

Problem

find_run (ai/run_store.py:371) validates run_id with re.match(r"^[a-zA-Z0-9_\-\.]+$", run_id). $ also matches before a trailing newline, so "abc\n" passes and goes into the glob pattern */{run_id}*.json. The lookup only reads, and a newline can't reach outside the runs directory, so the effect is limited to a lookup that finds nothing. The validation still says less than it means.

Copilot's re-review of release PR #905 mentioned this in its summary, without a thread. #682 added the check in v0.2.24.

Acceptance criteria

  • The check uses re.fullmatch (or \Z), and a test asserts that find_run("abc\n") returns None without globbing.
  • Any other ^...$ validation of an identifier in src/ that uses re.match is checked the same way and listed in the PR.
  • uv run devops ci passes.

Update 2026-10-08: refinement

find_run is now get_run (ai/run_store.py:388-393) with the same check. The first criterion reads: get_run("abc\n") returns None without globbing. Other $-terminated checks include core/validation.py:641, :667, ai/mcp/server.py:143, :3249 and telemetry/memory_profiler.py:347-348; the PR lists which it changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p3-lowscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions