Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item in response does not validate #430

Open
ghost opened this issue Apr 4, 2019 · 0 comments
Open

Item in response does not validate #430

ghost opened this issue Apr 4, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 4, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants