ldap-sync: add environments to new role entries

[PROBLEM]

The GrowthBook API's request-body schema for POST /members/:id/role requires every entry in member.projectRoles to include an environments field (typed as z.array(z.string()), not optional). Our project_roles_with_managed_set helper omitted the field when constructing new project role entries for users who didn't already have a managed-project entry. Sync against growthbook-next returns 400 for every user we try to add

[SOLUTION]

Append environments: [] to new project role entries. Empty array matches the GrowthBook UI's default for new entries (role applies in all environments, no env-restrictions). The update path (existing entry preserved via dict(entry)) was already fine because real GrowthBook responses include environments

[BUG ORIGIN]

This is a latent bug, not a recent GrowthBook API change. The require-environments constraint has been live since GrowthBook PR 5329 (Feb 2026), which predates growthbook-next's current image (Apr 10-13 2026 bump). Our script's first non-dry-run sync ran tonight (2026-05-18) and exposed it

See: https://github.com/growthbook/growthbook/pull/5329

Bug: T420691

Edited by Ryan Kemper

Merge request reports

Loading