TEST-INFRA: [coverage-gaps] Partial coverage (61%) for src/cleveragents/a2a/errors.py #2291

Open
opened 2026-04-03 13:01:53 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: test/a2a-errors-coverage
  • Commit Message: test(a2a): add BDD scenarios for A2A error hierarchy and domain error mapping
  • Milestone: v3.8.0
  • Parent Epic: #933

Background and Context

The file src/cleveragents/a2a/errors.py currently has 61% test coverage (41/67 lines). This file defines the complete A2A error hierarchy (A2aError, A2aNotAvailableError, A2aVersionMismatchError, A2aOperationNotFoundError) and the map_domain_error function that translates domain exceptions into structured A2A error codes for JSON-RPC 2.0 error responses (see spec §Standards Alignment — A2A).

The uncovered code falls into two categories:

  1. Exception constructors — the __init__ bodies of A2aError, A2aNotAvailableError, A2aVersionMismatchError, and A2aOperationNotFoundError are never exercised. This means the custom attributes (requested_version, supported_versions, operation) set by the constructors are untested.

  2. map_domain_error branches — the majority of the isinstance dispatch branches in map_domain_error are uncovered. Specifically, the mappings for ValidationError → VALIDATION_ERROR, PlanError → PLAN_ERROR, BusinessRuleViolation → INVALID_STATE, AuthenticationError → AUTH_ERROR, AuthorizationError → FORBIDDEN, ConfigurationError → CONFIGURATION_ERROR, CleverAgentsError → INTERNAL_ERROR, and the generic Exception → INTERNAL_ERROR fallback are all untested.

A file at 61% coverage violates the project's ≥ 97% coverage threshold and must be addressed.

Current Behavior

Running the coverage report shows src/cleveragents/a2a/errors.py at 61% line coverage. The following lines are uncovered:

  • Line 55: A2aError.__init__super().__init__(message, details) call
  • Line 66: A2aNotAvailableError.__init__super().__init__(message, details) call
  • Lines 79–81: A2aVersionMismatchError.__init__super().__init__ call and self.requested_version / self.supported_versions attribute assignments
  • Lines 93–94: A2aOperationNotFoundError.__init__super().__init__ call and self.operation attribute assignment
  • Lines 120–139: map_domain_error — all isinstance dispatch branches and their return statements (covering ValidationError, PlanError, BusinessRuleViolation, AuthenticationError, AuthorizationError, ConfigurationError, CleverAgentsError, and the bare Exception fallback)

No BDD scenarios exist that exercise these paths.

Expected Behavior

BDD scenarios exist that cover all exception constructors and all map_domain_error dispatch branches, verifying:

  • Each exception class can be instantiated and carries the expected message and custom attributes
  • A2aNotAvailableError uses its default message when no message is provided
  • A2aVersionMismatchError stores requested_version and supported_versions
  • A2aOperationNotFoundError stores operation
  • map_domain_error returns the correct (code, message) tuple for every mapped domain exception type
  • map_domain_error returns (INTERNAL_ERROR, ...) for an unmapped CleverAgentsError subclass
  • map_domain_error returns (INTERNAL_ERROR, ...) for a plain Exception (the fallback branch)
  • map_domain_error raises TypeError when passed a non-Exception argument

Acceptance Criteria

  • At least one Gherkin feature file covers the behaviour of all four exception classes and all branches of map_domain_error
  • All new scenarios are implemented with full step definitions (no placeholder steps)
  • Coverage for src/cleveragents/a2a/errors.py reaches 100%
  • Overall project coverage remains ≥ 97%
  • All nox default sessions pass without errors

Supporting Information

  • Uncovered paths summary:
    • A2aError(message, details) constructor
    • A2aNotAvailableError() with default message; A2aNotAvailableError(custom_message) with explicit message
    • A2aVersionMismatchError(message, requested_version, supported_versions) — verify .requested_version and .supported_versions attributes
    • A2aOperationNotFoundError(message, operation) — verify .operation attribute
    • map_domain_error(ValidationError(...))(VALIDATION_ERROR, ...)
    • map_domain_error(PlanError(...))(PLAN_ERROR, ...)
    • map_domain_error(BusinessRuleViolation(...))(INVALID_STATE, ...)
    • map_domain_error(AuthenticationError(...))(AUTH_ERROR, ...)
    • map_domain_error(AuthorizationError(...))(FORBIDDEN, ...)
    • map_domain_error(ConfigurationError(...))(CONFIGURATION_ERROR, ...)
    • map_domain_error(CleverAgentsError(...))(INTERNAL_ERROR, ...)
    • map_domain_error(Exception(...))(INTERNAL_ERROR, ...) (fallback)
    • map_domain_error("not an exception") → raises TypeError
  • Already covered: ResourceNotFoundError → NOT_FOUND mapping and the TypeError guard are the only currently exercised paths in map_domain_error
  • Related Epic: #933 (A2A Protocol Compliance — JSON-RPC 2.0 Framing, Standard Operations, and Extension Methods)
  • A2A architectural context: spec §Standards Alignment — A2A; ADR-047, ADR-048
  • Per CONTRIBUTING.md: BDD (Behave/Gherkin) is the required testing approach for unit-level scenarios

Subtasks

  • Identify or create the appropriate Behave feature file for a2a/errors exception and mapping behaviour (check for an existing a2a_errors feature file before creating a new one)
  • Write Gherkin scenarios covering all four exception constructors and their custom attributes
  • Write Gherkin scenarios covering all map_domain_error dispatch branches (one scenario per domain exception type)
  • Write a Gherkin scenario for the map_domain_error TypeError guard (non-Exception argument)
  • Implement all step definitions for the new scenarios (no placeholder steps)
  • Verify src/cleveragents/a2a/errors.py reaches 100% coverage via nox -s coverage_report
  • Verify overall project coverage remains ≥ 97%
  • Run nox (all default sessions) and fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (test(a2a): add BDD scenarios for A2A error hierarchy and domain error mapping), followed by a blank line, then additional lines providing relevant implementation details.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (test/a2a-errors-coverage).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage ≥ 97%.

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

## Metadata - **Branch**: `test/a2a-errors-coverage` - **Commit Message**: `test(a2a): add BDD scenarios for A2A error hierarchy and domain error mapping` - **Milestone**: v3.8.0 - **Parent Epic**: #933 ## Background and Context The file `src/cleveragents/a2a/errors.py` currently has **61% test coverage** (41/67 lines). This file defines the complete A2A error hierarchy (`A2aError`, `A2aNotAvailableError`, `A2aVersionMismatchError`, `A2aOperationNotFoundError`) and the `map_domain_error` function that translates domain exceptions into structured A2A error codes for JSON-RPC 2.0 error responses (see spec §Standards Alignment — A2A). The uncovered code falls into two categories: 1. **Exception constructors** — the `__init__` bodies of `A2aError`, `A2aNotAvailableError`, `A2aVersionMismatchError`, and `A2aOperationNotFoundError` are never exercised. This means the custom attributes (`requested_version`, `supported_versions`, `operation`) set by the constructors are untested. 2. **`map_domain_error` branches** — the majority of the `isinstance` dispatch branches in `map_domain_error` are uncovered. Specifically, the mappings for `ValidationError → VALIDATION_ERROR`, `PlanError → PLAN_ERROR`, `BusinessRuleViolation → INVALID_STATE`, `AuthenticationError → AUTH_ERROR`, `AuthorizationError → FORBIDDEN`, `ConfigurationError → CONFIGURATION_ERROR`, `CleverAgentsError → INTERNAL_ERROR`, and the generic `Exception → INTERNAL_ERROR` fallback are all untested. A file at 61% coverage violates the project's ≥ 97% coverage threshold and must be addressed. ## Current Behavior Running the coverage report shows `src/cleveragents/a2a/errors.py` at 61% line coverage. The following lines are uncovered: - **Line 55**: `A2aError.__init__` — `super().__init__(message, details)` call - **Line 66**: `A2aNotAvailableError.__init__` — `super().__init__(message, details)` call - **Lines 79–81**: `A2aVersionMismatchError.__init__` — `super().__init__` call and `self.requested_version` / `self.supported_versions` attribute assignments - **Lines 93–94**: `A2aOperationNotFoundError.__init__` — `super().__init__` call and `self.operation` attribute assignment - **Lines 120–139**: `map_domain_error` — all `isinstance` dispatch branches and their `return` statements (covering `ValidationError`, `PlanError`, `BusinessRuleViolation`, `AuthenticationError`, `AuthorizationError`, `ConfigurationError`, `CleverAgentsError`, and the bare `Exception` fallback) No BDD scenarios exist that exercise these paths. ## Expected Behavior BDD scenarios exist that cover all exception constructors and all `map_domain_error` dispatch branches, verifying: - Each exception class can be instantiated and carries the expected message and custom attributes - `A2aNotAvailableError` uses its default message when no message is provided - `A2aVersionMismatchError` stores `requested_version` and `supported_versions` - `A2aOperationNotFoundError` stores `operation` - `map_domain_error` returns the correct `(code, message)` tuple for every mapped domain exception type - `map_domain_error` returns `(INTERNAL_ERROR, ...)` for an unmapped `CleverAgentsError` subclass - `map_domain_error` returns `(INTERNAL_ERROR, ...)` for a plain `Exception` (the fallback branch) - `map_domain_error` raises `TypeError` when passed a non-`Exception` argument ## Acceptance Criteria - [ ] At least one Gherkin feature file covers the behaviour of all four exception classes and all branches of `map_domain_error` - [ ] All new scenarios are implemented with full step definitions (no placeholder steps) - [ ] Coverage for `src/cleveragents/a2a/errors.py` reaches 100% - [ ] Overall project coverage remains ≥ 97% - [ ] All `nox` default sessions pass without errors ## Supporting Information - **Uncovered paths summary**: - `A2aError(message, details)` constructor - `A2aNotAvailableError()` with default message; `A2aNotAvailableError(custom_message)` with explicit message - `A2aVersionMismatchError(message, requested_version, supported_versions)` — verify `.requested_version` and `.supported_versions` attributes - `A2aOperationNotFoundError(message, operation)` — verify `.operation` attribute - `map_domain_error(ValidationError(...))` → `(VALIDATION_ERROR, ...)` - `map_domain_error(PlanError(...))` → `(PLAN_ERROR, ...)` - `map_domain_error(BusinessRuleViolation(...))` → `(INVALID_STATE, ...)` - `map_domain_error(AuthenticationError(...))` → `(AUTH_ERROR, ...)` - `map_domain_error(AuthorizationError(...))` → `(FORBIDDEN, ...)` - `map_domain_error(ConfigurationError(...))` → `(CONFIGURATION_ERROR, ...)` - `map_domain_error(CleverAgentsError(...))` → `(INTERNAL_ERROR, ...)` - `map_domain_error(Exception(...))` → `(INTERNAL_ERROR, ...)` (fallback) - `map_domain_error("not an exception")` → raises `TypeError` - **Already covered**: `ResourceNotFoundError → NOT_FOUND` mapping and the `TypeError` guard are the only currently exercised paths in `map_domain_error` - Related Epic: #933 (A2A Protocol Compliance — JSON-RPC 2.0 Framing, Standard Operations, and Extension Methods) - A2A architectural context: spec §Standards Alignment — A2A; ADR-047, ADR-048 - Per CONTRIBUTING.md: BDD (Behave/Gherkin) is the required testing approach for unit-level scenarios ## Subtasks - [ ] Identify or create the appropriate Behave feature file for `a2a/errors` exception and mapping behaviour (check for an existing `a2a_errors` feature file before creating a new one) - [ ] Write Gherkin scenarios covering all four exception constructors and their custom attributes - [ ] Write Gherkin scenarios covering all `map_domain_error` dispatch branches (one scenario per domain exception type) - [ ] Write a Gherkin scenario for the `map_domain_error` `TypeError` guard (non-`Exception` argument) - [ ] Implement all step definitions for the new scenarios (no placeholder steps) - [ ] Verify `src/cleveragents/a2a/errors.py` reaches 100% coverage via `nox -s coverage_report` - [ ] Verify overall project coverage remains ≥ 97% - [ ] Run `nox` (all default sessions) and fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`test(a2a): add BDD scenarios for A2A error hierarchy and domain error mapping`), followed by a blank line, then additional lines providing relevant implementation details. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`test/a2a-errors-coverage`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage ≥ 97%. --- **Automated by CleverAgents Bot** Supervisor: Unknown | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-03 13:03:18 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High (confirmed) — 61% coverage on the A2A error hierarchy is a significant gap.
  • Milestone: v3.8.0 (confirmed)
  • MoSCoW: Could Have — Coverage gap for A2A error module. Important for quality but not blocking current milestones.
  • Parent Epic: #933 (confirmed correct)

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

Issue triaged by project owner: - **State**: Verified - **Priority**: High (confirmed) — 61% coverage on the A2A error hierarchy is a significant gap. - **Milestone**: v3.8.0 (confirmed) - **MoSCoW**: Could Have — Coverage gap for A2A error module. Important for quality but not blocking current milestones. - **Parent Epic**: #933 (confirmed correct) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#2291
No description provided.