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

Commitdb612b3

Browse files
committed
chore: reprot json error as param diagnostic
1 parent7a1622d commitdb612b3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎coderd/dynamicparameters/static.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (r *Loader) staticRender(ctx context.Context, db database.Store) (*staticRe
4848
},
4949
// Always use the default, since we used to assume the empty string
5050
Value:previewtypes.StringLiteral(it.DefaultValue),
51-
Diagnostics:nil,
51+
Diagnostics:make(previewtypes.Diagnostics,0),
5252
}
5353

5454
ifit.ValidationError!=""||it.ValidationRegex!=""||it.ValidationMonotonic!="" {
@@ -82,7 +82,15 @@ func (r *Loader) staticRender(ctx context.Context, db database.Store) (*staticRe
8282
}
8383

8484
varprotoOptions []*sdkproto.RichParameterOption
85-
_=json.Unmarshal(it.Options,&protoOptions)// Not going to make this fatal
85+
err:=json.Unmarshal(it.Options,&protoOptions)
86+
iferr!=nil {
87+
param.Diagnostics=append(param.Diagnostics,&hcl.Diagnostic{
88+
Severity:hcl.DiagError,
89+
Summary:"Failed to parse json parameter options",
90+
Detail:err.Error(),
91+
})
92+
}
93+
8694
for_,opt:=rangeprotoOptions {
8795
param.Options=append(param.Options,&previewtypes.ParameterOption{
8896
Name:opt.Name,
@@ -97,7 +105,7 @@ func (r *Loader) staticRender(ctx context.Context, db database.Store) (*staticRe
97105
// for a given set of conditions.
98106
_,param.FormType,_=provider.ValidateFormType(provider.OptionType(param.Type),len(param.Options),param.FormType)
99107

100-
param.Diagnostics=previewtypes.Diagnostics(param.Valid(param.Value))
108+
param.Diagnostics=append(param.Diagnostics,previewtypes.Diagnostics(param.Valid(param.Value))...)
101109
params=append(params,param)
102110
}
103111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp