Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: do not warn on valid known experiments #18514

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
Jun 24, 2025
Merged

Conversation

johnstcn
Copy link
Member

Fixes #18024

  • drive-by: renames handleExperimentsSafe to handleExperimentsAvailable to better match semantics
  • defines list of codersdk.ExperimentsKnown and updates ReadExperiments to log on invalid experiments
  • typescript-ignores codersdk.Experiments so apitypings generates a valid enum list of possible values of experiment
  • updates OverviewPageView to distinguish between known 'hidden' experiments and unknown 'invalid' experiments

@johnstcn johnstcn self-assigned this Jun 23, 2025
@johnstcn johnstcn requested review from Emyrk and mafredri June 23, 2025 20:22
Comment on lines +23 to +25
export const isKnownExperiment = (experiment: string): boolean => {
return Experiments.includes(experiment as Experiment);
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, we could have the FE return the list of known experiments, but it seems silly to do this when we can just use the auto-generated type.

Comment on lines 23 to +25
deploymentOptions: SerpentOption[];
dailyActiveUsers: DAUsResponse | undefined;
readonly invalidExperiments: Experiments | string[];
readonly safeExperiments: Experiments | string[];
readonly invalidExperiments: readonly string[];
Copy link
Member Author

Choose a reason for hiding this comment

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

review: this has to be a string because it might not be an Experiment

@@ -118,7 +118,7 @@ export const invalidExperimentsEnabled: Story = {
hidden: false,
},
],
safeExperiments: ["shared-ports"],
safeExperiments: ["example"],
Copy link
Member Author

Choose a reason for hiding this comment

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

review: using the "example" experiment enum here instead

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to me. Using a consistent experiment that we don't need to keep changing.

I wonder if example is the best name, but I do not have a better suggestion.

ExperimentPlaceholder, ExperimentDummy, idk.

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.

The nomenclature around available and safe feels inconsistent in the api and usage. But that is not introduced in this PR.

@@ -972,7 +972,7 @@ func New(options *Options) *API {
})
r.Route("/experiments", func(r chi.Router) {
r.Use(apiKeyMiddleware)
r.Get("/available", handleExperimentsSafe)
r.Get("/available", handleExperimentsAvailable)
Copy link
Member

Choose a reason for hiding this comment

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

Kinda unfortunate we have /available that returns only the safe experiments. Ideally there would be a /available and /safe. Or just have /available return a map[string]bool where the bool is true for safe or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I considered also returning all available experiments here but elected to keep the scope of this PR small.

Comment on lines +1898 to +1900
if !slice.Contains(codersdk.ExperimentsKnown, ex) {
log.Warn(context.Background(), "ignoring unknown experiment", slog.F("experiment", ex))
} else if !slice.Contains(codersdk.ExperimentsSafe, ex) {
Copy link
Member

Choose a reason for hiding this comment

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

👍.

@johnstcn johnstcn merged commit d892427 into main Jun 24, 2025
38 of 39 checks passed
@johnstcn johnstcn deleted the cj/ui-invalid-experiments branch June 24, 2025 08:14
@github-actions github-actions bot locked and limited conversation to collaborators Jun 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.

bug: valid experiments are showing as invalid on /deployment/overview
2 participants