Skip to content

fix: return non-zero exit for missing --template-info templates - #143

Merged
codeasier merged 1 commit into
mainfrom
fix/issue-112-template-info-exit-code
Sep 18, 2026
Merged

codeasier merged 1 commit into
mainfrom
fix/issue-112-template-info-exit-code

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

  • Make pt-snap query --template-info <missing> exit 1 instead of 0, while keeping Error: Template '...' not found.
  • Route the missing-template path through _error() so it matches other CLI failures (typer.Exit() defaults to 0).
  • Update the CLI and CLI/MCP contract tests that previously locked in success.

🔗 Related Issue

Fixes #112

🧪 Testing

  • Tests added/updated
  • Manual testing completed

Commands:

PYTHONPATH=src pytest tests/test_cli.py::TestQueryCommandErrors::test_query_template_info_not_found tests/test_contract_cli_mcp.py::test_missing_template_error_contract_matches_cli_and_mcp_semantics
PYTHONPATH=src pytest tests/test_cli.py tests/test_contract_cli_mcp.py
PYTHONPATH=src pytest
ruff check .
black --check .

Results: focused tests passed; CLI + contract suites 96 passed; full suite 860 passed, 1 xfailed; ruff and black clean.

✅ Checklist

  • Code follows project guidelines
  • Documentation updated (if applicable)
  • No new warnings introduced
  • Changes tested locally

Snapshot Runtime Provenance

  • Snapshot provenance evaluation completed when snapshot runtime files change
    Snapshot provenance decision: no-update
    Snapshot provenance no-update reason: This PR only changes CLI error handling and tests for --template-info; no file under src/pt_snap_cli/snapshot/ is created, modified, or deleted.

📸 Screenshots (if applicable)

Not applicable.

📋 Additional Notes

MCP get_template_info still returns {"error": "Template '...' not found"}. The CLI/MCP contract continues to compare that payload; only the CLI process exit code changes.

The pt-snap-memory-peak-breakdown skill still documents the old exit-0 preflight workaround. Output-record checks remain valid; the exit-code note is now stale and can be updated separately.

typer.Exit() defaults to 0, so scripts and agent preflight could not tell a missing template from a successful lookup.
@codeasier
codeasier merged commit fb90e7f into main Sep 18, 2026
6 checks passed
@codeasier
codeasier deleted the fix/issue-112-template-info-exit-code branch October 3, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] query --template-info 对缺失模板仍返回退出码 0

1 participant