-
Notifications
You must be signed in to change notification settings - Fork 3
Bug: TypeError: can't access property "self", data._jv.links is undefined on patchRelated #15
Copy link
Copy link
Open
Description
🐛 Bug: TypeError: can't access property "self", data._jv.links is undefined on patchRelated
Description
A TypeError is thrown when performing a PATCH request on a relationship endpoint.
The error occurs even though the server response appears to be a valid JSON:API document.
This seems to happen because the response does not include links.self, and the client code attempts to access it unconditionally.
Error
TypeError: can't access property "self", data._jv.links is undefined
writeRelated actions.js:75
patchRelated actions.js:276
wrappedAction pinia.mjs:1400
actionName pinia.mjs:955
Endpoint
PATCH /some-resource/resource-4e4e-467a-8f7c-uuid/relationships/some-related-resource
Request Body
{
"data": [
{
"type": "some-related-resource",
"id": "some-85ca-43ed-8028-uuid"
}
]
}Response Body
{
"jsonapi": {
"version": "1.0"
},
"data": [
{
"type": "some-related-resource",
"id": "some-85ca-43ed-8028-uuid"
}
]
}Expected Behavior
- The relationship update succeeds without throwing an error.
- The client should either:
- Handle responses without
links.self, or - Accept a
204 No Contentresponse for relationshipPATCHrequests, which is valid per JSON:API.
- Handle responses without
Actual Behavior
- The request succeeds server-side, but the client throws:
TypeError: can't access property "self", data._jv.links is undefined - Execution fails in
writeRelated / patchRelated.
Notes
- According to the JSON:API specification, a
PATCHrequest to a relationship endpoint may return204 No Content, and response bodies are optional. - When a response body is returned,
linksare optional and should not be assumed to exist.
Possible Fix
- Add a null/undefined guard when accessing
data._jv.links.self - Or skip link processing for relationship
PATCHresponses
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels