ApiError Rejects Server Payloads Due to Missing Field Alias #8346

Open
opened 2026-04-13 11:08:11 +00:00 by HAL9000 · 1 comment
Owner

Background:
The ApiError model in src/cleveragents/domain/models/auth/auth.py is used to deserialize error payloads from the server.

Current Behavior:
The ApiError model uses the attribute name type_ to avoid the Python keyword type, but it does not provide an alias for the JSON field type. This causes a ValidationError when deserializing real error payloads from the server, which use the type field.

Expected Behavior:
The ApiError model should correctly deserialize error payloads from the server by using an alias for the type field.

Steps to Reproduce:

  1. Trigger any API call that returns an error block (e.g., an expired token).
  2. The infrastructure layer attempts to construct ApiError.
  3. Deserialization fails with a ValidationError for a missing type_ field.

Acceptance Criteria:

  • The ApiError model is updated to include alias="type" for the type_ field.
  • Error payloads from the server are correctly deserialized without any validation errors.
  • Unit tests are added to verify the fix.

Commit Message:
fix(domain): add field alias for ApiError.type_

Branch Name:
bugfix/domain-api-error-alias


Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor

**Background:** The `ApiError` model in `src/cleveragents/domain/models/auth/auth.py` is used to deserialize error payloads from the server. **Current Behavior:** The `ApiError` model uses the attribute name `type_` to avoid the Python keyword `type`, but it does not provide an alias for the JSON field `type`. This causes a `ValidationError` when deserializing real error payloads from the server, which use the `type` field. **Expected Behavior:** The `ApiError` model should correctly deserialize error payloads from the server by using an alias for the `type` field. **Steps to Reproduce:** 1. Trigger any API call that returns an error block (e.g., an expired token). 2. The infrastructure layer attempts to construct `ApiError`. 3. Deserialization fails with a `ValidationError` for a missing `type_` field. **Acceptance Criteria:** - The `ApiError` model is updated to include `alias="type"` for the `type_` field. - Error payloads from the server are correctly deserialized without any validation errors. - Unit tests are added to verify the fix. **Commit Message:** fix(domain): add field alias for ApiError.type_ **Branch Name:** bugfix/domain-api-error-alias --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
Author
Owner

🟡 Triage Decision: Should Have — Functional Bug

Verified by: Project Owner Supervisor [AUTO-OWNR-1]
MoSCoW: Should Have
Priority: High

This is a functional bug that should be fixed for production quality. It does not block core functionality but degrades reliability or correctness.

Rationale: Functional correctness bugs are Should Have items. They should be addressed within the current milestone cycle but are not release blockers on their own.


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

## 🟡 Triage Decision: Should Have — Functional Bug **Verified by:** Project Owner Supervisor [AUTO-OWNR-1] **MoSCoW:** Should Have **Priority:** High This is a functional bug that should be fixed for production quality. It does not block core functionality but degrades reliability or correctness. **Rationale:** Functional correctness bugs are Should Have items. They should be addressed within the current milestone cycle but are not release blockers on their own. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

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