mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
Addresses https://github.com/coder/coder/issues/16455. ## Changes - Initialize default entitlements in a Set to include all features - Initialize entitlements' `Warnings` and `Errors` fields to arrays rather than `nil`s. - Minor changes in formatting on the frontend ## Reasoning I had to change how entitlements are initialized to match the `codersdk` [generated types](33d6261922/site/src/api/typesGenerated.ts (L727)
), which the frontend assumes are correct, and doesn't run additional checks on. - `features: Record<FeatureName, Feature>`: this type signifies that every `FeatureName` is present in the record, but on `main`, that's not true if there's a telemetry required error - `warnings: readonly string[];` and `errors: readonly string[];`: these types mean that the fields are not `null`, but that's not always true With a valid license, the [`LicensesEntitlements` function](33d6261922/enterprise/coderd/license/license.go (L92)
) ensures that all features are present in the entitlements. It's called by the [`Entitlements` function](33d6261922/enterprise/coderd/license/license.go (L42)
), which is called by [`api.updateEnittlements`](33d6261922/enterprise/coderd/coderd.go (L687)
). However, when a license requires telemetry and telemetry is disabled, the entitlements with all features [are discarded](33d6261922/enterprise/coderd/coderd.go (L704)
) in an early exit from the same function. By initializing entitlements with all the features from the get go, we avoid this problem. ## License issue banner after the changes <img width="1512" alt="Screenshot 2025-02-23 at 20 25 42" src="https://github.com/user-attachments/assets/ee0134b3-f745-45d9-8333-bfa1661e33d2" />