asset merge happens only for map type in `UpsertPatchAsset`
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.
@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?
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)
- Accept that asset merge will only happen at map level and any slice Kind will be overwritten in API documentation as a limitation
- Enforce only one source per asset type when pushing to compass.
- 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?