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

RefactortemplateVersionDynamicParameters to remove control flag and send websocket errors #18478

Open
Assignees
Emyrk
@Emyrk

Description

@Emyrk

This code currently operates with a control flaglisten

// The `listen` control flag determines whether to open a websocket connection to
// handle the request or not. This same function is used to 'evaluate' a template
// as a single invocation, or to 'listen' for a back and forth interaction with
// the user to update the form as they type.
//
//nolint:revive // listen is a control flag
func (api*API)templateVersionDynamicParameters(listenbool,initial codersdk.DynamicParametersRequest)func(rw http.ResponseWriter,r*http.Request) {
returnfunc(rw http.ResponseWriter,r*http.Request) {
ctx:=r.Context()
templateVersion:=httpmw.TemplateVersionParam(r)
renderer,err:=dynamicparameters.Prepare(ctx,api.Database,api.FileCache,templateVersion.ID,
dynamicparameters.WithTemplateVersion(templateVersion),
)
iferr!=nil {
ifhttpapi.Is404Error(err) {
httpapi.ResourceNotFound(rw)
return
}
ifxerrors.Is(err,dynamicparameters.ErrTemplateVersionNotReady) {
httpapi.Write(ctx,rw,http.StatusTooEarly, codersdk.Response{
Message:"Template version job has not finished",
})
return
}
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
Message:"Internal error fetching template version data.",
Detail:err.Error(),
})
return
}
deferrenderer.Close()
iflisten {
api.handleParameterWebsocket(rw,r,initial,renderer)
}else {
api.handleParameterEvaluate(rw,r,initial,renderer)
}
}
}

This requires anolint and should be fixed. Additionally, http errors are not well received by websocket based FE requests. These errors should be translated to the websocket message to be properly rendered on the FE.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp