Skip to content

V4 SDK corrupts multiple expand query parameters #157

@ChrisCrossKudos

Description

@ChrisCrossKudos

Background Context

Merge's REST api has always required multiple expand values to be comma separated. The online docs still spell this out today:

Image

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:

Image

The Problem

In the newest v4 SDK, merge requires you to pass in the expand parameter as an array (enforced by Typescript types):

Image

But when you do that it builds the query parameters wrongly. Here is an example where groups and work_location were requested:

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions