Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ca90ae

Browse files
fix: handle null value for experiments (#17584)
Fix#17583**Relevant info**- `option.value` can be `null`- It is always better to use `unknown` instead of `any`, and use typeassertion functions as `Array.isArray()` before using/accessing objectproperties and functions
1 parent0a26eee commit5ca90ae

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

‎site/src/pages/DeploymentSettingsPage/optionValue.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ describe("optionValue", () => {
120120
additionalValues:["single_tailnet"],
121121
expected:{single_tailnet:true},
122122
},
123+
{
124+
option:{
125+
...defaultOption,
126+
name:"Experiments",
127+
value:null,
128+
},
129+
additionalValues:["single_tailnet"],
130+
expected:"",
131+
},
123132
{
124133
option:{
125134
...defaultOption,

‎site/src/pages/DeploymentSettingsPage/optionValue.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ export function optionValue(
4040
case"Experiments":{
4141
constexperimentMap=additionalValues?.reduce<Record<string,boolean>>(
4242
(acc,v)=>{
43-
// biome-ignore lint/suspicious/noExplicitAny: opt.value is any
44-
acc[v]=(option.valueasany).includes("*");
43+
constisIncluded=Array.isArray(option.value)
44+
?option.value.includes("*")
45+
:false;
46+
acc[v]=isIncluded;
4547
returnacc;
4648
},
4749
{},
@@ -57,10 +59,11 @@ export function optionValue(
5759

5860
// We show all experiments (including unsafe) that are currently enabled on a deployment
5961
// but only show safe experiments that are not.
60-
// biome-ignore lint/suspicious/noExplicitAny: opt.value is any
61-
for(constvofoption.valueasany){
62-
if(v!=="*"){
63-
experimentMap[v]=true;
62+
if(Array.isArray(option.value)){
63+
for(constvofoption.value){
64+
if(v!=="*"){
65+
experimentMap[v]=true;
66+
}
6467
}
6568
}
6669
returnexperimentMap;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp