Skip to content

POST /api/v1/settings/attributes – entity_type accepts empty or invalid values without validation #117

Open
@sagarkumar-webkul

Description

@sagarkumar-webkul

API Issue Report


Title

POST /api/v1/settings/attributes – entity_type accepts empty or invalid values without validation


Description

The /api/v1/settings/attributes endpoint allows the creation of an attribute even when the required field entity_type is passed as an empty string or an invalid value. This results in inconsistent records being saved in the system.


Preconditions

  1. Endpoint: POST /api/v1/settings/attributes
  2. Required Field: entity_type
  3. Issue: API accepts "" (empty) or invalid values for this field

Steps to Reproduce

  1. Send a POST request with an invalid or empty entity_type:

    curl -X POST 'http://<host>/api/v1/settings/attributes' \
    -H 'accept: application/json' \
    -H 'Authorization: Bearer <token>' \
    -H 'Content-Type: application/json' \
    -H 'X-CSRF-TOKEN: <token>' \
    -d '{
        "code": "sdsdaff",
        "name": "dsq",
        "type": "select",
        "lookup_type": "safd",
        "entity_type": "",
        "sort_order": "1",
        "validation": "",
        "is_required": "1",
        "is_unique": "1",
        "quick_add": "1",
        "is_user_defined": "1",
        "option_type": "options"
    }'
  2. Observe the response:

    {
      "message": "Attribute created successfully.",
      ...
    }

Expected Result

  • The API should return a 422 Unprocessable Entity status.
  • A validation error should be shown:
    {
      "errors": {
        "entity_type": ["The entity type field is required and must contain a valid value."]
      }
    }

Actual Result

  • Attribute gets created successfully even with empty or invalid entity_type.
  • HTTP Status: 200 OK
  • No validation error is triggered.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions