UAT: agents resource type add --update does not overwrite existing type — aborts with "Update mode is not yet fully supported" #2047

Open
opened 2026-04-03 03:37:15 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/resource-type-add-update-flag-overwrite
  • Commit Message: fix(cli): implement --update flag overwrite in agents resource type add command
  • Milestone: v3.7.0
  • Parent Epic: #936

Background and Context

UAT testing of the agents resource type add --update command revealed a functional regression against the specification. When the --update flag is passed and the target resource type already exists, the command aborts with an unsupported message instead of overwriting the existing type definition.

Specification Reference (docs/specification.md, line 9890):

--update: If the type name already exists, overwrite it. Without this flag, adding a duplicate name fails with an error.

Code Locationsrc/cleveragents/cli/commands/resource.py, lines 204–215:

if update:
    # Try to register; if it already exists, show a message
    try:
        spec = service.register_type(config)
    except ValidationError as exc:
        if "already exists" in str(exc):
            console.print(
                "[yellow]Resource type already exists. "
                "Update mode is not yet fully supported.[/yellow]"
            )
            raise typer.Abort() from exc
        raise

The register_type() service method (in src/cleveragents/application/services/resource_registry_service.py, lines 263–270) raises ValidationError when the type already exists. The CLI handler catches this and aborts instead of performing the overwrite.

Related BDD testfeatures/resource_cli_coverage.feature, scenario "type add with --update flag on existing type" (lines 11–17) was written to match the broken behavior (expects failure with "already exists") rather than the spec-required behavior (expects success/overwrite). This test must also be corrected as part of this fix.

Steps to Reproduce

  1. Register a custom resource type: agents resource type add --config ./my-type.yaml
  2. Run again with the update flag: agents resource type add --config ./my-type.yaml --update
  3. Observe: command aborts with "Resource type already exists. Update mode is not yet fully supported." and exits with a non-zero code.

Expected Behavior

The command should remove the existing type definition and register the new one from the YAML config file, effectively overwriting it. On success it should print the registered type details (per the spec-defined rich output panels).

Actual Behavior

Resource type already exists. Update mode is not yet fully supported.

Command aborts (exits with non-zero code) instead of overwriting.

Subtasks

  • In resource_registry_service.py: implement an update_type() (or register_type(overwrite=True)) method that deletes the existing type and registers the new definition atomically
  • In resource.py type_add(): when --update is set and the type already exists, call the overwrite path instead of catching and aborting
  • Remove the "Update mode is not yet fully supported" abort branch entirely
  • Update the BDD scenario "type add with --update flag on existing type" in features/resource_cli_coverage.feature to assert successful overwrite behavior (not failure)
  • Add a new Behave scenario: --update on a type that does NOT yet exist behaves identically to a normal add (no error)
  • Add a Behave scenario: duplicate add WITHOUT --update still fails with the correct error
  • Add Robot Framework integration tests for --update overwrite and non---update duplicate-rejection paths
  • Run nox -e typecheck — fix any type errors introduced
  • Run nox -e unit_tests and nox -e integration_tests — all must pass
  • Verify coverage ≥ 97% via nox -e coverage_report
  • Run full nox (all default sessions) — fix any remaining errors

Definition of Done

  • agents resource type add --config <file> --update successfully overwrites an existing resource type and prints the registered type details
  • agents resource type add --config <file> --update on a non-existent type behaves identically to a normal add (no error)
  • agents resource type add --config <file> (without --update) on an existing type still fails with the correct duplicate-name error
  • The BDD scenario in features/resource_cli_coverage.feature is corrected to assert the spec-required overwrite behavior
  • No "Update mode is not yet fully supported" message exists anywhere in the codebase
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation, and a footer ISSUES CLOSED: #<this issue number>
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed by at least two contributors, and merged before this issue is marked done
  • All nox stages pass
  • Coverage ≥ 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/resource-type-add-update-flag-overwrite` - **Commit Message**: `fix(cli): implement --update flag overwrite in agents resource type add command` - **Milestone**: v3.7.0 - **Parent Epic**: #936 ## Background and Context UAT testing of the `agents resource type add --update` command revealed a functional regression against the specification. When the `--update` flag is passed and the target resource type already exists, the command aborts with an unsupported message instead of overwriting the existing type definition. **Specification Reference** (`docs/specification.md`, line 9890): > `--update`: If the type name already exists, overwrite it. Without this flag, adding a duplicate name fails with an error. **Code Location** — `src/cleveragents/cli/commands/resource.py`, lines 204–215: ```python if update: # Try to register; if it already exists, show a message try: spec = service.register_type(config) except ValidationError as exc: if "already exists" in str(exc): console.print( "[yellow]Resource type already exists. " "Update mode is not yet fully supported.[/yellow]" ) raise typer.Abort() from exc raise ``` The `register_type()` service method (in `src/cleveragents/application/services/resource_registry_service.py`, lines 263–270) raises `ValidationError` when the type already exists. The CLI handler catches this and aborts instead of performing the overwrite. **Related BDD test** — `features/resource_cli_coverage.feature`, scenario "type add with --update flag on existing type" (lines 11–17) was written to match the broken behavior (expects failure with "already exists") rather than the spec-required behavior (expects success/overwrite). This test must also be corrected as part of this fix. ## Steps to Reproduce 1. Register a custom resource type: `agents resource type add --config ./my-type.yaml` 2. Run again with the update flag: `agents resource type add --config ./my-type.yaml --update` 3. **Observe**: command aborts with `"Resource type already exists. Update mode is not yet fully supported."` and exits with a non-zero code. ## Expected Behavior The command should remove the existing type definition and register the new one from the YAML config file, effectively overwriting it. On success it should print the registered type details (per the spec-defined rich output panels). ## Actual Behavior ``` Resource type already exists. Update mode is not yet fully supported. ``` Command aborts (exits with non-zero code) instead of overwriting. ## Subtasks - [ ] In `resource_registry_service.py`: implement an `update_type()` (or `register_type(overwrite=True)`) method that deletes the existing type and registers the new definition atomically - [ ] In `resource.py` `type_add()`: when `--update` is set and the type already exists, call the overwrite path instead of catching and aborting - [ ] Remove the `"Update mode is not yet fully supported"` abort branch entirely - [ ] Update the BDD scenario "type add with --update flag on existing type" in `features/resource_cli_coverage.feature` to assert successful overwrite behavior (not failure) - [ ] Add a new Behave scenario: `--update` on a type that does NOT yet exist behaves identically to a normal add (no error) - [ ] Add a Behave scenario: duplicate add WITHOUT `--update` still fails with the correct error - [ ] Add Robot Framework integration tests for `--update` overwrite and non-`--update` duplicate-rejection paths - [ ] Run `nox -e typecheck` — fix any type errors introduced - [ ] Run `nox -e unit_tests` and `nox -e integration_tests` — all must pass - [ ] Verify coverage ≥ 97% via `nox -e coverage_report` - [ ] Run full `nox` (all default sessions) — fix any remaining errors ## Definition of Done - [ ] `agents resource type add --config <file> --update` successfully overwrites an existing resource type and prints the registered type details - [ ] `agents resource type add --config <file> --update` on a non-existent type behaves identically to a normal add (no error) - [ ] `agents resource type add --config <file>` (without `--update`) on an existing type still fails with the correct duplicate-name error - [ ] The BDD scenario in `features/resource_cli_coverage.feature` is corrected to assert the spec-required overwrite behavior - [ ] No `"Update mode is not yet fully supported"` message exists anywhere in the codebase - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation, and a footer `ISSUES CLOSED: #<this issue number>` - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - [ ] The commit is submitted as a **pull request** to `master`, reviewed by at least two contributors, and **merged** before this issue is marked done - [ ] All nox stages pass - [ ] Coverage ≥ 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-03 03:37:26 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High (confirmed) — The --update flag is a spec-defined feature (line 9890) that is completely non-functional. The command aborts with "Update mode is not yet fully supported" instead of performing the overwrite. This is a functional regression against the spec.
  • Milestone: v3.7.0 (confirmed — part of the Output Rendering Pipeline Epic #936)
  • MoSCoW: Should Have — The --update flag is a spec-defined feature for agents resource type add. While the command works for initial adds, the update path is broken. This is important for spec compliance but not blocking core functionality since users can manually delete and re-add types as a workaround.
  • Parent Epic: #936 (confirmed correct)

Well-documented issue with clear root cause analysis, code locations, and a comprehensive fix plan including BDD test corrections.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: High (confirmed) — The `--update` flag is a spec-defined feature (line 9890) that is completely non-functional. The command aborts with "Update mode is not yet fully supported" instead of performing the overwrite. This is a functional regression against the spec. - **Milestone**: v3.7.0 (confirmed — part of the Output Rendering Pipeline Epic #936) - **MoSCoW**: Should Have — The `--update` flag is a spec-defined feature for `agents resource type add`. While the command works for initial adds, the update path is broken. This is important for spec compliance but not blocking core functionality since users can manually delete and re-add types as a workaround. - **Parent Epic**: #936 (confirmed correct) Well-documented issue with clear root cause analysis, code locations, and a comprehensive fix plan including BDD test corrections. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo self-assigned this 2026-04-03 16:58:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#2047
No description provided.