Skip to content

patch: Graceful error when project type has no manifest support (closes #50)#51

Merged
rdwj merged 1 commit into
mainfrom
fix/50-graceful-unsupported-type
May 7, 2026
Merged

patch: Graceful error when project type has no manifest support (closes #50)#51
rdwj merged 1 commit into
mainfrom
fix/50-graceful-unsupported-type

Conversation

@rdwj
Copy link
Copy Markdown
Collaborator

@rdwj rdwj commented May 7, 2026

Closes #50.

Before this change, running `fips-agents patch check`, `patch `, or `patch all` against a project whose template type is not in the built-in category set (today: sandbox) AND does not ship a `.fips-template.yaml` manifest produced a Python traceback ending in `ValueError`.

Fix

Sentinel exception `PatchUnsupportedForProjectType`, raised by `_resolve_categories` when the manifest is unusable AND `get_categories_for_type` raises. Three CLI entry points catch it and emit a single-line ✗ message:

```
$ fips-agents patch check
✗ Patching is not supported for project type 'sandbox'. The template repo
for this project type does not yet ship a .fips-template.yaml manifest, and
no built-in category set exists for it. See
#45 for the manifest
schema.
```

Same shape for `patch chart` and `patch all`. All exit 1.

Call site changes

  • `patch check` wraps `check_for_updates` in try/except.
  • `patch_category` (used by every `patch ` subcommand) defers the pre-clone fast-fail when there is no built-in category set for the type, then catches `PatchUnsupportedForProjectType` post-clone and returns `(False, message)` so the existing red ✗ rendering kicks in.
  • `patch all` wraps the pre-clone `get_available_categories` call and exits 1 cleanly. (Iterating manifest-declared categories without a Click subcommand for each is a bigger refactor — out of scope.)

Test plan

  • 4 new unit cases in `TestPatchUnsupportedForProjectType` covering the exception type, message content, and that supported types (agent / mcp-server / workflow) still fall back to constants.
  • 4 new integration cases in `TestPatchUnsupportedTypeE2E` against a fake sandbox project — `patch check`, `patch chart`, `patch all` all exit 1 with no traceback. A future-proofing test confirms that once sandbox ships a manifest, `patch check` works without further CLI changes.
  • Full suite: 343 passed (was 334 on main → +9 new).
  • `black src tests` clean.
  • `ruff check src tests` clean.
  • gitleaks clean.
  • Manual e2e — scaffold a real sandbox project, verify each command produces a clean message and exits 1.

Out of scope

  • Functional patch support for sandbox — that needs a `.fips-template.yaml` shipped in `fips-agents/code-sandbox`. This PR only ensures the failure mode is graceful, not the success mode.

Closes #50.

Before this change, running `fips-agents patch check`, `patch <category>`,
or `patch all` against a project whose template type is not in the
built-in category set (today: sandbox) AND does not ship a
.fips-template.yaml manifest produced a Python traceback ending in
ValueError. The user has no idea what went wrong.

This change introduces a sentinel exception
`PatchUnsupportedForProjectType`, raised by `_resolve_categories` when
the manifest is unusable AND `get_categories_for_type` raises. Each
CLI entry point catches it and emits a single-line ✗ message that
explains:

  - the project type isn't patchable;
  - the template needs to ship a .fips-template.yaml manifest;
  - link to issue #45 for the schema.

Three call sites updated:

  - `patch check` wraps `check_for_updates` and exits 1.
  - `patch_category` (used by every `patch <category>`) defers the
    pre-clone fast-fail when there's no built-in category set, then
    catches `PatchUnsupportedForProjectType` post-clone and returns
    `(False, message)` so the existing red ✗ rendering kicks in.
  - `patch all` wraps the pre-clone `get_available_categories` call
    and exits 1 with the clean message.

Tests cover the new exception (4 unit cases) and end-to-end CLI
behavior against a fake sandbox project — `patch check`, `patch chart`,
and `patch all` all exit 1 with no traceback. A future-proofing test
confirms that once the sandbox template ships its own manifest,
`patch check` works against it without changes to the CLI.

Assisted-by: Claude Code (Opus 4.7)
@rdwj rdwj merged commit 45c7bc8 into main May 7, 2026
5 checks passed
@rdwj rdwj deleted the fix/50-graceful-unsupported-type branch May 7, 2026 00:29
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.

patch: Graceful error when an unsupported project type has no manifest

1 participant