Skip to content

Merge nested objects in default transformation for same key #115

Open
@riyaagrahari

Description

Spec Config

[
  {
    "operation": "default",
    "spec": {
      "data.amount": "200",
      "data.receipt": "transaction2",
      "data.currency": "INR",
      "data.notes": {
        "beta": "transaction2",
        "alpha": "test notes"
      },
      "data.notes.fund_account_id": "a_JMjPtaaaaaaaaaa"
    }
  }
]

Input {}

Expected Output

{
  "data": {
    "amount": "200",
    "receipt": "transaction2",
    "currency": "INR",
    "notes": {
      "alpha": "test notes",
      "beta": "transaction2",
      "fund_account_id": "fa_JMjPtaaaaaaaaaa"
    }
  }
}

Facing intermittent merge failures for data.notes child objects. Sometimes we get output as expected and sometimes it's overriding the child object during merge and resolution for same key.

Intermittent incorrect output

{
  "data": {
    "amount": "200",
    "receipt": "transaction2",
    "currency": "INR",
    "notes": {
      "alpha": "test notes",
      "beta": "transaction2",
    }
  }
}

data.notes.fund_account_id is getting overwritten by data.notes, if it gets iterated first. This is possibly happening due to random order of map (*spec.Spec) while iterating in default.go.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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