Source pointer format for relationship error?


#1

I am using ember-data and marshmallow-jsonapi, respectively, for my frontend and backend. If a relationship has an error, marshmallow-jsonapi adds /data to the end of the pointer path. However, when ember-data serializes those errors, it appends ‘/data’ to the relationship attribute name, e.g. institution/data instead of institution.

So what is the correct format for the pointer of a relationship?

  1. “pointer”: “/data/relationships/institution/data”
  2. “pointer”: “/data/relationships/institution”

#2

Hm, had I similar question I typed into google and ended up here. I could not find anything specific to errors on relationships, neihter here http://jsonapi.org/format/#error-objects nor there http://jsonapi.org/examples/#error-objects-source-usage

To me, it would also make sense to have something like

{
  "code":   "226",
  "source": { "relationship": "institution" },
  "title": "Institution missing"
}

I don’t know how ember data handles either error source pointer you presented. But arguably, one cannot know exactly how to construct errors for relationships from the jsonapi specification.


#3

Extrapolating based on the example in the JSON API docs:

[e.g. “/data” for a
primary data object, or “/data/attributes/title” for a specific attribute].

It seems to me that if there is a problem with the relationship in general (e.g., it is not allowed), then the pointer should be to “the primary relationship object”, that is /data/relationships/institution/data.

Whereas if there is a problem with the id (it does not exist) then the pointer should be /data/relationships/institution/data/id.

To me this seems inline with the specification, and is coincidentally also the conclusion marshmallow-jsonapi came to.

In the end though, since it isn’t strongly specified, I’m not sure it matters so much, as long as the pointer is a valid JSON pointer and makes sense in the context of the error.