Hugo Dutka
ac88c9ba17
fix: ensure the web UI doesn't break when license telemetry required check fails (#16667)
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](https://github.com/coder/coder/blob/33d62619225702257fa2542f40ecc26bfd0d1fa6/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](https://github.com/coder/coder/blob/33d62619225702257fa2542f40ecc26bfd0d1fa6/enterprise/coderd/license/license.go#L92)
ensures that all features are present in the entitlements. It's called
by the [`Entitlements`
function](https://github.com/coder/coder/blob/33d62619225702257fa2542f40ecc26bfd0d1fa6/enterprise/coderd/license/license.go#L42),
which is called by
[`api.updateEnittlements`](https://github.com/coder/coder/blob/33d62619225702257fa2542f40ecc26bfd0d1fa6/enterprise/coderd/coderd.go#L687).
However, when a license requires telemetry and telemetry is disabled,
the entitlements with all features [are
discarded](https://github.com/coder/coder/blob/33d62619225702257fa2542f40ecc26bfd0d1fa6/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"
/>
2025-02-24 16:02:33 +01:00
..
2025-02-20 14:52:01 +02:00
2024-03-13 12:03:36 +02:00
2025-02-21 18:42:16 +01:00
2024-06-03 12:29:50 -05:00
2024-09-18 21:47:53 +10:00
2025-02-20 14:52:01 +02:00
2025-01-17 14:51:53 +02:00
2023-10-30 19:44:29 +00:00
2024-05-28 16:45:41 +00:00
2025-01-08 15:38:37 +00:00
2025-02-20 16:33:14 +01:00
2025-02-20 16:33:14 +01:00
2024-12-10 08:51:46 +05:00
2025-02-24 16:02:33 +01:00
2024-12-03 13:26:31 -06:00
2023-08-18 18:55:43 +00:00
2025-01-29 18:06:22 +02:00
2025-02-21 16:26:07 -05:00
2025-02-21 18:42:16 +01:00
2024-07-11 13:38:33 -06:00
2025-01-31 12:14:24 -07:00
2025-01-03 11:21:49 -06:00
2024-11-18 14:09:22 +04:00
2025-02-19 13:08:38 +00:00
2025-02-10 09:31:08 -06:00
2024-05-13 14:37:51 -04:00
2024-11-18 14:09:22 +04:00
2024-10-25 12:14:15 -04:00
2025-02-20 05:09:26 +00:00
2024-07-25 16:08:12 -05:00
2025-02-21 14:33:34 -07:00
2024-07-08 15:38:50 +02:00
2025-01-30 10:52:50 -07:00
2024-12-20 09:52:03 +00:00
2025-02-17 13:02:30 +00:00
2025-02-03 14:50:55 +01:00
2024-10-25 15:14:39 +01:00
2025-01-15 20:51:32 +11:00
2025-01-08 15:38:37 +00:00
2025-01-08 15:38:37 +00:00
2024-11-05 17:22:32 +01:00
2025-02-17 16:56:52 +00:00
2025-01-03 11:21:49 -06:00
2025-01-29 14:35:04 +00:00
2025-02-12 14:41:14 +02:00
2024-11-01 14:17:05 +11:00
2024-11-18 14:09:22 +04:00
2024-10-01 09:01:24 +00:00
2024-09-18 21:23:42 +10:00
2023-08-18 18:55:43 +00:00
2024-08-01 12:07:19 -05:00
2025-02-17 13:02:30 +00:00
2025-02-17 13:02:30 +00:00
2024-07-19 15:44:18 -05:00
2024-07-29 19:58:48 -05:00
2023-08-18 18:55:43 +00:00
2025-02-12 09:23:28 +01:00
2025-01-08 15:38:37 +00:00
2025-02-21 18:42:16 +01:00
2023-08-18 18:55:43 +00:00
2024-03-26 12:44:31 -05:00
2024-09-03 10:32:33 -05:00
2024-02-27 16:33:32 +00:00
2024-05-15 11:09:42 -05:00
2024-06-11 12:22:59 +10:00
2023-10-17 14:49:19 -04:00
2023-10-17 14:49:19 -04:00
2024-09-10 15:58:50 +01:00
2024-09-10 15:58:50 +01:00
2024-11-08 18:24:12 +11:00
2024-11-08 18:24:12 +11:00
2024-07-30 10:44:02 -06:00
2023-09-01 16:50:12 +00:00
2024-10-07 21:10:01 +02:00
2025-01-17 11:55:41 -06:00
2025-01-16 17:34:53 +02:00
2023-06-06 10:26:13 -05:00
2024-09-17 10:42:47 -05:00
2024-11-08 08:44:14 -06:00
2025-02-19 13:08:38 +00:00
2025-02-21 13:54:29 +01:00
2024-03-25 11:52:22 -08:00
2024-07-11 13:38:33 -06:00
2024-07-25 16:07:53 -05:00
2024-08-28 13:24:28 -05:00
2024-03-05 14:05:15 +00:00
2024-06-28 07:38:04 -05:00
2025-02-20 09:58:04 +02:00
2025-02-20 09:58:04 +02:00
2025-02-17 14:34:47 +02:00
2025-02-18 14:14:30 +00:00
2024-12-19 00:51:30 +04:00
2025-02-13 18:24:27 +02:00
2025-02-18 14:14:30 +00:00
2024-07-25 16:07:53 -05:00
2024-08-05 13:42:11 -05:00
2024-11-18 14:09:22 +04:00
2024-11-20 18:04:33 +11:00
2024-11-18 14:09:22 +04:00
2025-01-17 11:55:41 -06:00
2025-02-20 05:09:26 +00:00
2025-01-14 16:43:42 +00:00
2023-08-18 18:55:43 +00:00
2023-08-18 18:55:43 +00:00
2025-02-21 18:42:16 +01:00
2025-02-21 18:42:16 +01:00
2025-02-10 09:31:08 -06:00
2025-01-30 17:44:04 +00:00
2024-10-22 09:20:54 -05:00
2024-05-13 14:37:51 -04:00
2025-02-20 05:09:26 +00:00
2025-02-21 12:21:20 +11:00
2024-12-19 00:51:30 +04:00
2024-10-25 16:49:44 +00:00
2025-02-20 14:52:01 +02:00
2024-11-18 14:09:22 +04:00
2024-10-25 17:14:35 +01:00
2025-02-20 05:09:26 +00:00
2025-01-30 17:44:04 +00:00
2024-01-18 09:44:05 -06:00
2024-01-18 09:44:05 -06:00
2025-02-20 05:09:26 +00:00
2023-08-18 18:55:43 +00:00
2025-02-20 05:09:26 +00:00
2025-01-30 17:44:04 +00:00
2024-11-18 14:09:22 +04:00
2024-11-01 14:53:53 +11:00