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

Presence of _expand key in Partij depends on number of elements in expanded key #243

Open
swrichards opened this issue Sep 10, 2024 · 1 comment
Assignees
Labels
approved bug Something isn't working owner: dimpact

Comments

@swrichards
Copy link

swrichards commented Sep 10, 2024

Product versie / Product version

2.2.0

Omschrijf het probleem / Describe the bug

Retrieving a single Partij resource with expand=digitaleAdressen only includes the _expand.digitaleAdresssen key if the number of digitaleAddressen is >0:.

Stappen om te reproduceren / Steps to reproduce

  1. Fetch a Partij without digitaleAddressen, which yields a resource without an _expand key and with an [] digitaleAdresssen key:
curl -s -X GET  \
  'http://localhost:8000/klantinteracties/api/v1/partijen/65440202-dad5-4012-aa59-bc9645d950ba?expand=digitaleAdressen' \
  -H 'Authorization: Token *** '\
  | jq
{
  "uuid": "65440202-dad5-4012-aa59-bc9645d950ba",
  "url": "http://localhost:8000/klantinteracties/api/v1/partijen/65440202-dad5-4012-aa59-bc9645d950ba",
  "nummer": "0000000137",
  "interneNotitie": "",
  "betrokkenen": [],
  "categorieRelaties": [],
   // Empty list, no _expand key
  "digitaleAdressen": [],
  "voorkeursDigitaalAdres": null,
  "vertegenwoordigden": [],
  "rekeningnummers": [],
  "voorkeursRekeningnummer": null,
  "partijIdentificatoren": [],
  "soortPartij": "organisatie",
  "indicatieGeheimhouding": false,
  "voorkeurstaal": "tiv",
  "indicatieActief": true,
  "bezoekadres": {
    "nummeraanduidingId": "",
    "adresregel1": "",
    "adresregel2": "",
    "adresregel3": "",
    "land": ""
  },
  "correspondentieadres": {
    "nummeraanduidingId": "",
    "adresregel1": "",
    "adresregel2": "",
    "adresregel3": "",
    "land": ""
  },
  "partijIdentificatie": {
    "naam": "Test Organisatie"
  }
}
  1. Create a digitaal adres for this user:
curl -s -X POST \
  'http://localhost:8000/klantinteracties/api/v1/digitaleadressen' \
  -H 'Authorization: Token ***' \
  -H 'Content-Type: application/json' \
  -d '{"adres": "12345667", "soortDigitaalAdres": "telnr", "verstrektDoorPartij": {"uuid": "65440202-dad5-4012-aa59-bc9645d950ba"},"verstrektDoorBetrokkene": null,"omschrijving": "foobar"}' \
  jq
{
  "uuid": "14b3c631-236b-4b41-8b33-883bda62dc9d",
  "url": "http://localhost:8000/klantinteracties/api/v1/digitaleadressen/14b3c631-236b-4b41-8b33-883bda62dc9d",
  "verstrektDoorBetrokkene": null,
  "verstrektDoorPartij":
    {
      "uuid": "65440202-dad5-4012-aa59-bc9645d950ba",
      "url": "http://localhost:8000/klantinteracties/api/v1/partijen/65440202-dad5-4012-aa59-bc9645d950ba",
    },
  "adres": "12345667",
  "soortDigitaalAdres": "telnr",
  "omschrijving": "foobar",
}
  1. Re-fetch the object, note the _expand key is now present, as the number of digitaleAdressen is now 1.
curl -s -X GET  \
  'http://localhost:8000/klantinteracties/api/v1/partijen/65440202-dad5-4012-aa59-bc9645d950ba?expand=digitaleAdressen'   \
  -H 'Authorization: Token ***'  \
   | jq                                                                                                                
{
  "uuid": "65440202-dad5-4012-aa59-bc9645d950ba",
  "url": "http://localhost:8000/klantinteracties/api/v1/partijen/65440202-dad5-4012-aa59-bc9645d950ba",
  "nummer": "0000000137",
  "interneNotitie": "",
  "betrokkenen": [],
  "categorieRelaties": [],
  "digitaleAdressen": [
    {
      "uuid": "14b3c631-236b-4b41-8b33-883bda62dc9d",
      "url": "http://localhost:8000/klantinteracties/api/v1/digitaleadressen/14b3c631-236b-4b41-8b33-883bda62dc9d"
    }
  ],
  "voorkeursDigitaalAdres": null,
  "vertegenwoordigden": [],
  "rekeningnummers": [],
  "voorkeursRekeningnummer": null,
  "partijIdentificatoren": [],
  "soortPartij": "organisatie",
  "indicatieGeheimhouding": false,
  "voorkeurstaal": "tiv",
  "indicatieActief": true,
  "bezoekadres": {
    "nummeraanduidingId": "",
    "adresregel1": "",
    "adresregel2": "",
    "adresregel3": "",
    "land": ""
  },
  "correspondentieadres": {
    "nummeraanduidingId": "",
    "adresregel1": "",
    "adresregel2": "",
    "adresregel3": "",
    "land": ""
  },
  "partijIdentificatie": {
    "naam": "Test Organisatie"
  },
  "_expand": {
    "digitaleAdressen": [
      {
        "uuid": "14b3c631-236b-4b41-8b33-883bda62dc9d",
        "url": "http://localhost:8000/klantinteracties/api/v1/digitaleadressen/14b3c631-236b-4b41-8b33-883bda62dc9d",
        "verstrektDoorBetrokkene": null,
        "verstrektDoorPartij": {
          "uuid": "65440202-dad5-4012-aa59-bc9645d950ba",
          "url": "http://localhost:8000/klantinteracties/api/v1/partijen/65440202-dad5-4012-aa59-bc9645d950ba"
        },
        "adres": "12345667",
        "soortDigitaalAdres": "telnr",
        "omschrijving": "foobar"
      }
    ]
  }
}

Verwacht gedrag / Expected behavior

If I provide the expand=digitaleAdressen key, I would expect to always receive the same object shape: if there are no resources, I would simply expect an empty list. The shape should not vary depending on the object state (apart from e.g. nullability and such). Currently, the client has to build in additional guards to check for the shape.

@swrichards swrichards added bug Something isn't working triage labels Sep 10, 2024
@joeribekker
Copy link
Member

Agree with this finding.
Estimate: 2 days
Needs stakeholder, assuming Dimpact because Sidney reported it.

@mariusvandam needs approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved bug Something isn't working owner: dimpact
Projects
Status: Todo
Development

No branches or pull requests

3 participants