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

Merge nested objects in default transformation for same key #115

Open
riyaagrahari opened this issue May 18, 2022 · 0 comments
Open

Merge nested objects in default transformation for same key #115

riyaagrahari opened this issue May 18, 2022 · 0 comments

Comments

@riyaagrahari
Copy link

riyaagrahari commented May 18, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant