Background Context
Merge's REST api has always required multiple expand values to be comma separated. The online docs still spell this out today:
This is backed up by testing with the API tester. If you repeat the ?expand= parameter multiple times, ONLY the last one wins. There is no error, but the earlier expand parameters are ignored. In this example below, you can see that the groups are NOT expanded but the work location is:
The Problem
In the newest v4 SDK, merge requires you to pass in the expand parameter as an array (enforced by Typescript types):
But when you do that it builds the query parameters wrongly. Here is an example where groups and work_location were requested:
This URL is logged via the page.rawResponse.url property when you fetch the employees list. This is the URL that merge SDK built and used for the request. As you can see, the expand parameter is repeated multiple times, which means only the last one actually takes effect
Summary
- Merge SDK v4.0.3 forces, via typescript typing, that the expand parameter be supplied as an array instead of CSV value
- Attempting to fetch resources with more than one
expand field results in incomplete data because only the last one is respected
- The only way to workaround this is to use
expand: 'work_location,groups' as Merge.hris.EmployeesListRequestExpandItem typescript hack to trick it into using comma separated values
Impact
- Definitely affects Employees list endpoint, I suspect this affects all resource types though.
- Because there is no error thrown, this bug is very difficult to notice and results in data loss during syncs
Background Context
Merge's REST api has always required multiple expand values to be comma separated. The online docs still spell this out today:
This is backed up by testing with the API tester. If you repeat the
?expand=parameter multiple times, ONLY the last one wins. There is no error, but the earlierexpandparameters are ignored. In this example below, you can see that the groups are NOT expanded but the work location is:The Problem
In the newest v4 SDK, merge requires you to pass in the expand parameter as an array (enforced by Typescript types):
But when you do that it builds the query parameters wrongly. Here is an example where
groupsandwork_locationwere requested:This URL is logged via the
page.rawResponse.urlproperty when you fetch the employees list. This is the URL that merge SDK built and used for the request. As you can see, theexpandparameter is repeated multiple times, which means only the last one actually takes effectSummary
expandfield results in incomplete data because only the last one is respectedexpand: 'work_location,groups' as Merge.hris.EmployeesListRequestExpandItemtypescript hack to trick it into using comma separated valuesImpact