Skip to content

Related relationships links returned incorrectly in example app #49

@jcampbell

Description

@jcampbell

I can provide the following steps to reproduce, but I have not been able to understand yet what's causing the issue, so I wanted to open this ticket to flag it.

  1. Run the example api.py.
  2. Post a new object to /persons:
{
  "data": {
    "type": "person",
    "attributes": {
      "name": "Person1"
    }
  }
}
  1. Get the person's (empty) relationships object at /persons/1/relationships/computers
{
  "links": {
    "self": "/persons/1/relationships/computers",
    "related": "/persons/1/computers"
  },
  "data": [],
  "jsonapi": {
    "version": "1.0"
  }
}
  1. Post a new object to /persons
{
  "data": {
    "type": "person",
    "attributes": {
      "name": "Person2"
    }
  }
}
  1. Observe that the "relationships" -> "computers" -> "links" -> "related" url is incorrect (refers to person 1). That appears to stick through other permutations (subsequent gets), but depends on having queried previously for another person's relationships.
{
  "data": {
    "type": "person",
    "id": "2",
    "attributes": {
      "display_name": "PERSON2 <None>",
      "birth_date": null
    },
    "relationships": {
      "computers": {
        "links": {
          "self": "/persons/2/relationships/computers",
          "related": "/persons/1/computers"
        }
      }
    },
    "links": {
      "self": "/persons/2"
    }
  },
  "links": {
    "self": "/persons/2"
  },
  "jsonapi": {
    "version": "1.0"
  }
}

I have not investigated deeply enough to understand why this is happening (or tested outside of the example sqlite), but wanted to open the issue in hopes the author can identify the problem since it definitely doesn't seem to match the JSONAPI spec or desired behavior.

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