UAT: ResourceTypeConfigSchema does not validate that virtual resource types have handler: null — spec requires virtual types to have no handler #5928

Open
opened 2026-04-09 11:53:17 +00:00 by HAL9000 · 2 comments
Owner

Bug Report

Feature Area: Resource Management — Resource YAML Configuration / Schema Validation
Milestone Scope: v3.6.0 (resource type schema, ADR-008)
Severity: Low — schema allows invalid configurations that the spec prohibits


What Was Tested

Code-level analysis of src/cleveragents/resource/schema.py ResourceTypeConfigSchema.validate_cross_fields() method against the spec.

Expected Behavior (from spec)

Per docs/reference/resource_types_builtin.md:

Virtual types represent abstract identities that link equivalent physical resources across layers and repositories. Virtual types have no handler, no sandbox strategy, and are never user-addable.

Per docs/specification.md (Physical vs Virtual Resources section):

Virtual resource types have handler: null — they are never directly resolved or sandboxed.

The schema should enforce this constraint: if resource_kind: virtual, then handler must be null/None.

Actual Behavior

ResourceTypeConfigSchema.validate_cross_fields() currently validates:

  1. Custom types must be namespaced
  2. Virtual types require equivalence configuration
  3. Cannot inherit from self
  4. Built-in types cannot inherit from custom types

But it does NOT validate:

  1. Virtual types must have handler: null

This means a YAML file like the following would pass schema validation:

name: my-org/bad-virtual
resource_kind: virtual
sandbox_strategy: none
user_addable: false
handler: "my_module:MyHandler"   # ← should be rejected
equivalence:
  criteria: [content_hash]
  description: "..."

Code Location

src/cleveragents/resource/schema.py, ResourceTypeConfigSchema.validate_cross_fields() method.

Steps to Reproduce

  1. Create a YAML string with resource_kind: virtual and a non-null handler value
  2. Call ResourceTypeConfigSchema.from_yaml(yaml_string)
  3. Observe: validation passes without error — the invalid handler is accepted

Impact

  • Users can define virtual resource types with handlers, which contradicts the spec
  • If such a type is registered, the system may attempt to use the handler for a virtual resource, causing unexpected behavior
  • The spec's invariant (virtual types have no handler) is not enforced at the schema level

Fix

Add a cross-field validation rule in validate_cross_fields():

# Virtual types must not have a handler
if self.resource_kind == "virtual" and self.handler is not None:
    raise ValueError(
        f"Virtual resource type '{self.name}' must not have a handler. "
        "Virtual types represent abstract identities and are never directly "
        "resolved or sandboxed. Set 'handler: null' or omit the handler field."
    )

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area**: Resource Management — Resource YAML Configuration / Schema Validation **Milestone Scope**: v3.6.0 (resource type schema, ADR-008) **Severity**: Low — schema allows invalid configurations that the spec prohibits --- ## What Was Tested Code-level analysis of `src/cleveragents/resource/schema.py` `ResourceTypeConfigSchema.validate_cross_fields()` method against the spec. ## Expected Behavior (from spec) Per `docs/reference/resource_types_builtin.md`: > **Virtual types** represent abstract identities that link equivalent physical resources across layers and repositories. Virtual types have **no handler**, no sandbox strategy, and are never user-addable. Per `docs/specification.md` (Physical vs Virtual Resources section): > Virtual resource types have `handler: null` — they are never directly resolved or sandboxed. The schema should enforce this constraint: if `resource_kind: virtual`, then `handler` must be `null`/`None`. ## Actual Behavior `ResourceTypeConfigSchema.validate_cross_fields()` currently validates: 1. ✅ Custom types must be namespaced 2. ✅ Virtual types require `equivalence` configuration 3. ✅ Cannot inherit from self 4. ✅ Built-in types cannot inherit from custom types But it does **NOT** validate: 5. ❌ Virtual types must have `handler: null` This means a YAML file like the following would pass schema validation: ```yaml name: my-org/bad-virtual resource_kind: virtual sandbox_strategy: none user_addable: false handler: "my_module:MyHandler" # ← should be rejected equivalence: criteria: [content_hash] description: "..." ``` ## Code Location `src/cleveragents/resource/schema.py`, `ResourceTypeConfigSchema.validate_cross_fields()` method. ## Steps to Reproduce 1. Create a YAML string with `resource_kind: virtual` and a non-null `handler` value 2. Call `ResourceTypeConfigSchema.from_yaml(yaml_string)` 3. Observe: validation passes without error — the invalid handler is accepted ## Impact - Users can define virtual resource types with handlers, which contradicts the spec - If such a type is registered, the system may attempt to use the handler for a virtual resource, causing unexpected behavior - The spec's invariant (virtual types have no handler) is not enforced at the schema level ## Fix Add a cross-field validation rule in `validate_cross_fields()`: ```python # Virtual types must not have a handler if self.resource_kind == "virtual" and self.handler is not None: raise ValueError( f"Virtual resource type '{self.name}' must not have a handler. " "Virtual types represent abstract identities and are never directly " "resolved or sandboxed. Set 'handler: null' or omit the handler field." ) ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-09 12:21:09 +00:00
Author
Owner

Label compliance fix applied:

  • Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Label compliance fix applied: - Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Author
Owner

Hierarchical Compliance Fix: This issue was detected as an orphan (no parent Epic).

Solution: Linked to Epic #5176 (Extended Resource Types — Cloud Infrastructure, Database & Virtual Resources) as virtual resource type validation is part of the extended resource types scope.

Hierarchy: Issue #5928 → Epic #5176 → Legendary #4945


Automated by CleverAgents Bot
Supervisor: Epic Planning | Agent: epic-planner

**Hierarchical Compliance Fix**: This issue was detected as an orphan (no parent Epic). **Solution**: Linked to Epic #5176 (Extended Resource Types — Cloud Infrastructure, Database & Virtual Resources) as virtual resource type validation is part of the extended resource types scope. **Hierarchy**: Issue #5928 → Epic #5176 → Legendary #4945 --- **Automated by CleverAgents Bot** Supervisor: Epic Planning | Agent: epic-planner
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#5928
No description provided.