Skip to content

Incorrect error code when sending empty string for transaction description field #1915

@gandalf-at-lerian

Description

@gandalf-at-lerian

Bug Description

When sending an empty string ("") for the description field in the POST /transactions endpoint, Midaz returns an incorrect error code. The field is optional and should accept either a valid string value, null, or be omitted entirely from the request payload — but the error response when an empty string is provided uses a wrong/misleading error code.

Steps to Reproduce

  1. Send a POST request to /v1/transactions (or /v1/transactions/json)
  2. Include "description": "" (empty string) in the request body
  3. Observe the error response

Expected Behavior

  • If description is provided, it should be a non-empty string
  • If not needed, the field should be sent as null or omitted from the payload
  • When an empty string is sent, the error code returned should accurately describe the validation failure (e.g., invalid value for optional field)

Actual Behavior

The error code returned for an empty string description is incorrect/misleading, making it harder for clients to understand and handle the error properly.

Additional Context

Reported by the operations team based on client feedback. The description field behavior itself is correct (rejects empty strings), but the mapped error code needs to be fixed to properly communicate the issue to API consumers.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions