Skip to content

fix: ensure the web UI doesn't break when license telemetry required check fails #16667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2025

Conversation

hugodutka
Copy link
Contributor

@hugodutka hugodutka commented Feb 23, 2025

Addresses #16455.

Changes

  • Initialize default entitlements in a Set to include all features
  • Initialize entitlements' Warnings and Errors fields to arrays rather than nils.
  • Minor changes in formatting on the frontend

Reasoning

I had to change how entitlements are initialized to match the codersdk generated types, 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 ensures that all features are present in the entitlements. It's called by the Entitlements function, which is called by api.updateEnittlements. However, when a license requires telemetry and telemetry is disabled, the entitlements with all features are discarded 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

Screenshot 2025-02-23 at 20 25 42

@hugodutka hugodutka force-pushed the hugodutka/require-telemetry-frontend-fix branch from 1c7cb66 to ef80b4f Compare February 24, 2025 11:49
@hugodutka hugodutka marked this pull request as ready for review February 24, 2025 12:28
@hugodutka hugodutka requested a review from Emyrk February 24, 2025 12:28
Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hugodutka hugodutka merged commit ac88c9b into main Feb 24, 2025
37 of 39 checks passed
@hugodutka hugodutka deleted the hugodutka/require-telemetry-frontend-fix branch February 24, 2025 15:02
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants