Skip to content

Item in response does not validate #430

Open
@ghost

Description

How to reproduce:

Make a simple POST to create a data sample but don't include the attribute "type":

        "data": {
            "attributes": {
                "userId": "1",
                "caseId": "1",
                "score": 1,
                "createdAt": "2016-04-04T13:43:52Z",
                "updatedAt": "2016-04-04T13:43:52Z"
            }
        }

The body of the request is not valid, but it will not be discarded and persisted anyway. As response I will get:

"errors": [
        {
            "status": "500",
            "code": "EINVALIDITEM",
            "title": "Item in response does not validate",
            "detail": {
                "item": {
                    "type": "userCourseHighscore",
                    "id": "791e942b-9487-4887-8f20-456e1477a5ab",
                    "userId": "1",
                    "courseId": null,
                    "score": "1",
                    "createdAt": "2016-04-04T13:43:52.000Z",
                    "updatedAt": "2016-04-04T13:43:52.000Z"
                },
                "error": "child \"type\" fails because [\"type\" must be one of [userCaseHighscore]]"
            }
        }
    ]

If I request all items of the relation with a GET, I will get the same error.

 "errors": [
        {
            "status": "500",
            "code": "EINVALIDITEM",
            "title": "Item in response does not validate",
            "detail": {
                "item": {
                    "type": "userCourseHighscore",
                    "id": "05173fba-0574-418e-9edf-b0e284c0490c",
                    "userId": "1",
                    "courseId": null,
                    "score": "1",
                    "createdAt": "2016-04-04T13:43:52.000Z",
                    "updatedAt": "2016-04-04T13:43:52.000Z"
                },
                "error": "child \"type\" fails because [\"type\" must be one of [userCaseHighscore]]"
            }
        }
    ]

Expected Behavior

If the payload doesn't validate, the item should be disgarded and not persisted.

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