The Updating Resources section of the spec says:
A server MUST return
404 Not Found
when processing a request that references a related resource that does not exist.
This contradicts RFC 7231 § 6.5.4, which clearly refers to the target resource (i.e. the request URI).
If that’s OK by your compatibility policy, I suggest removing or relaxing this requirement of JSON API. If not, then at least a note is in order.
A better status code may be 422 (Unprocessable Entity), defined by WebDAV (RFC 4918 § 11.2) but widely used elsewhere.