From fddbecdbf02cf7d45f7ab48421bea2f841f1a65e Mon Sep 17 00:00:00 2001 From: CleverThis Date: Sun, 17 May 2026 02:47:21 +0000 Subject: [PATCH] fix(resources): add missing resource_type field and step definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes remaining blockers from Re-Review #12 (PR #10592): - Add `resource_type` field to CloudResource base class, satisfying issue #8607 acceptance criterion that requires provider, region, resource_type, resource_id fields. - Set `resource_type` in the Behave step definition for the resource_type acceptance scenario (changed pending_resource key from "type" to "resource_type"). - Fix the result_type assertion step to check resource_type instead of type. - Add missing step definition `step_rejects_empty_tag_key` that matches the feature file scenario "AWSResource validates tags", preventing UndefinedStep errors in Behave. Quality gates: lint ✅ (passed) typecheck ✅ (passed, only pre-existing warnings) ISSUES CLOSED: #8607 --- features/steps/cloud_types_steps.py | 14 ++++++++++++-- src/cleveragents/resource/cloud_types.py | 10 +++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/features/steps/cloud_types_steps.py b/features/steps/cloud_types_steps.py index 93cd446f1..6158b546c 100644 --- a/features/steps/cloud_types_steps.py +++ b/features/steps/cloud_types_steps.py @@ -78,7 +78,7 @@ def step_new_cloud_resource_with_type(context, resource_type: str): """Store a CloudResource with specified resource_type for construction.""" context.pending_resource = { "resource_id": "cloud-test-001", - "type": resource_type, + "resource_type": resource_type, } @@ -98,7 +98,7 @@ def step_cloud_resource_type_accepted(context): def step_resource_type_is(context, expected: str): """Assert the constructed resource has the expected resource_type.""" assert context.exc is None - assert context.result.type == expected + assert context.result.resource_type == expected @given("a new AWSResource is being created") @@ -250,6 +250,16 @@ def step_azure_subscription_is_lowercase(context): assert context.result.subscription_id == "sub-123" +# --------------------- AWSResource tag validation ---------------------------- + + +@then("it should reject tags with empty key") +def step_rejects_empty_tag_key(context): + """Assert a ValidationError was raised for an empty tag key.""" + assert context.exc is not None + assert isinstance(context.exc, ValidationError) + + # ------------------------ GCPResource provider assertion -------------------- diff --git a/src/cleveragents/resource/cloud_types.py b/src/cleveragents/resource/cloud_types.py index f6f096be9..146f5ce19 100644 --- a/src/cleveragents/resource/cloud_types.py +++ b/src/cleveragents/resource/cloud_types.py @@ -12,7 +12,7 @@ cloud SDK operations -- actual provisioning raises | Class | Provider | Key properties | |-----------------|--------------|--------------------------------------------| -| ``CloudResource`` | generic | provider, type, region, resrc id, state | +| ``CloudResource`` | generic | provider, resource_type, type, region, id | | ``AWSResource`` | AWS | arn, tags, properties | | ``GCPResource`` | GCP | project_id, properties | | ``AzureResource`` | Azure | sub_id, tenant_id, props | @@ -62,6 +62,13 @@ class CloudResource(BaseModel): ..., description="Cloud provider identifier (aws, gcp, azure).", ) + resource_type: str | None = Field( + default=None, + description=( + "Type of cloud resource within a provider " + "(e.g., s3_bucket, ec2_instance, gcs_bucket, compute_instance)." + ), + ) type: str | None = Field( default=None, description=( @@ -136,6 +143,7 @@ class CloudResource(BaseModel): return ( f"{self.__class__.__name__}(" f"provider={self.provider!r}, " + f"resource_type={self.resource_type!r}, " f"type={self.type!r}, " f"resource_id={self.resource_id!r}, " f"region={self.region!r})"