Skip to content

cowork: CLI error observability + --output robustness - #65

Draft
Coding-Dev-Tools wants to merge 1 commit into
mainfrom
cowork/improve-api-contract-guardian
Draft

cowork: CLI error observability + --output robustness#65
Coding-Dev-Tools wants to merge 1 commit into
mainfrom
cowork/improve-api-contract-guardian

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Summary

  • Spec-load errors now print to a stderr Rich console, keeping stdout clean for CI pipelines consuming --format json/yaml output (silent-failure trap: previously errors could interleave with machine-readable output).
  • All --output writes route through a helper that creates missing parent directories instead of crashing with an unhandled FileNotFoundError.
  • Retired placeholder tests/test_dummy.py (a pass-only test that inflated pass counts) — moved to _archive/retired-tests/.
  • Added regression tests for stderr error routing and nested --output paths.

Verification

  • pytest: 191 passed (was 192 incl. dummy; net +2 real tests)
  • ruff check src tests: clean

cowork-bot commit 0047b49

- Spec-load errors now print to a stderr console so stdout stays clean for
  CI pipes consuming --format json/yaml output
- All --output writes go through a helper that creates missing parent dirs
  instead of crashing with FileNotFoundError
- Retire placeholder test_dummy.py (inflated pass counts, tested nothing)
  by moving it to _archive/retired-tests/
- Add regression tests for stderr error routing and nested --output paths
@github-actions

Copy link
Copy Markdown

🤖 Automated Code Review

✅ Ruff Lint — No issues

⚠️ Ruff Format — Formatting needed

unformatted: File would be reformatted
   --> src/api_contract_guardian/cli.py:21:19
    |
20  |
    -     warnings.warn(
    -         "revenueholdings-license not installed; license checks skipped", stacklevel=2
    -     )
21  +     warnings.warn("revenueholdings-license not installed; license checks skipped", stacklevel=2)
22  |     _has_rh = False
--------------------------------------------------------------------------------
53  |
    - def _validate_output_format(
    -     format_name: str, allowed: tuple[str, ...], command: str
    - ) -> str:
54  + def _validate_output_format(format_name: str, allowed: tuple[str, ...], command: str) -> str:
55  |     """Reject unsupported output formats before the command runs."""
56  |     if format_name not in allowed:
57  |         allowed_list = ", ".join(allowed)
    -         raise typer.BadParameter(
    -             f"Unsupported {command} format '{format_name}'. Choose from: {allowed_list}"
    -         )
58  +         raise typer.BadParameter(f"Unsupported {command} format '{format_name}'. Choose from: {allowed_list}")
59  |     return format_name
--------------------------------------------------------------------------------
110 |     global _require_license_strict
    -     _require_license_strict = require_license_flag or bool(
    -         os.environ.get("REVENUEHOLDINGS_REQUIRE_LICENSE")
    -     )
111 +     _require_license_strict = require_license_flag or bool(os.environ.get("REVENUEHOLDINGS_REQUIRE_LICENSE"))
112 |

✅ Secret Detection — Clean

✅ Large Files — Within limits

📊 Diff Stats — 3 file(s) changed

 {tests => _archive/retired-tests}/test_dummy.py |  0
 src/api_contract_guardian/cli.py                | 33 ++++++++++++++++++-------
 tests/test_cli.py                               | 19 ++++++++++++++
 3 files changed, 43 insertions(+), 9 deletions(-)

Verdict: ⚠️ Warnings — Lint/format issues found. Recommend fixing before merge.

Automated by Coding-Dev-Tools/.github reusable workflow.

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.

1 participant