Skip to content

API: Structured error response format #688

@vprashrex

Description

@vprashrex

Is your feature request related to a problem?
The POST /configs/{id}/versions endpoint currently returns a raw Pydantic ValidationError string instead of structured field-level errors. This inconsistency hinders effective error handling and debugging.

Describe the solution you'd like

  • Return structured errors in the response, similar to other endpoints.
  • Ensure the errors are formatted in an array with field and message attributes.
Original issue

Describe the bug
The POST /configs/{id}/versions endpoint returns raw Pydantic ValidationError string in the error field instead of structured field-level errors in the errors array. This is inconsistent with other validation errors.

To Reproduce

  1. Create a config with a valid config_blob
  2. Call POST /configs/{id}/versions with an invalid partial update (e.g., provider: "openai" instead of "openai-native", or temperature: 10)
  3. See the raw error string in the response

Expected behavior
Response should return structured errors like other endpoints:

{
    "success": false,
    "data": null,
    "error": "Validation failed",
    "errors": [
        {
            "field": "name",
            "message": "Field required"
        },
        {
            "field": "config_blob.completion.provider",
            "message": "Field required"
        },
        {
            "field": "config_blob.completion.type",
            "message": "Field required"
        }
    ],
    "metadata": null
}

Screenshots

Image

Additional context
Now validation error would be like this:

    "success": false,
    "data": null,
    "error": "Validation failed",
    "errors": [
        {
            "field": "name",
            "message": "Field required"
        },
        {
            "field": "config_blob.completion.provider",
            "message": "Field required"
        },
        {
            "field": "config_blob.completion.type",
            "message": "Field required"
        }
    ],
    "metadata": null
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions