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

asset merge happens only for map type in UpsertPatchAsset #173

Open
bsushmith opened this issue Sep 21, 2022 · 2 comments
Open

asset merge happens only for map type in UpsertPatchAsset #173

bsushmith opened this issue Sep 21, 2022 · 2 comments

Comments

@bsushmith
Copy link
Member

Describe the bug
In the UpsertPatchAsset method, asset merge happens only when the nested kind is map type. If the nested kind is slice type, it simply overwrites the field. It's how the library that is used works internally.

This causes an issue in the scenario - where there are two sources that push metadata to compass for the same asset - one being meteor and the other - some internal tool.
In this case:

  • When a user has added certain fields either one-time or through an internal tool based on business logic, to the asset. The asset merge will overwrite whenever the meteor runs and pushes the data.

Expected behavior
Asset merge should happen even at the nested slice level.

@StewartJingga
Copy link
Contributor

@bsushmith what would be the expected behaviour when merging slice?

Should it always append? If not, how do we check if incoming item in the list already exists in the current slice?

@bsushmith
Copy link
Member Author

bsushmith commented Sep 21, 2022

Since there is no inherent type information available when merge happens, everything is either map[string]interface{} or interface{} or []interface{}. Finding which element exists in slice and which does not etc and take appropriate merge action is super difficult if not impossible without any type info. 😭

We can either - (just listing some options here; not exhaustive)

  1. Accept that asset merge will only happen at map level and any slice Kind will be overwritten in API documentation as a limitation
  2. Enforce only one source per asset type when pushing to compass.
  3. Propose to send type/proto information along with the source, and compass will merge based on the proto definition from a defined schema registry.

WDYT?

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

2 participants