flattenClaims can lead to data loss with objects in lists

Issue #188 wontfix
Laurens created an issue

I was playing around with the results of the flattenClaims() call and noticed that due to the lack of index, objects nested in a list overwrite each others fields. E.g.:

  "anArray": [
    {},
    {
      "aNestedKey": "value1",
      "aSpecificKey": "aSpecificValue"
    },
    {
      "aNestedKey": "value2",
      "aRandomKey": "someValue"
    }
  ]

results in

anArray.aNestedKey=[value2], anArray.aSpecificKey=[aSpecificValue], anArray.aRandomKey=[someValue], anArray=[]

When multiple objects have the same keys, only the value from the last object will be retained. Perhaps adding an index for each object in the list might solve this issue? e.g.

anArray.[1].aNestedKey=[value1], anArray.[1].aSpecificKey=[aSpecificValue], anArray.[2].aNestedKey=[value2], anArray.[2].aRandomKey=[someValue], anArray.[0]=[]

The above is not an issue for me at the current time, but I thought it was worth bringing to your attention.

Comments (2)

  1. Brian Campbell

    Yeah, that’s just how it works. flattenClaims was an attempt to provide a simplified (maybe) representation of the claims and based on likely or expected claims content. It’s not intended to be prefect. Adding an index like that would be a potentially breaking change to existing usages of it. Which is something I’d like to avoid, on the off-chance that it is being used.

  2. Log in to comment