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

Commit37f6b38

Browse files
authored
fix: return 403 when rebuilding workspace with require_active_version (#11114)
1 parent8488afa commit37f6b38

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

‎cli/restart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r *RootCmd) restart() *clibase.Cmd {
6363
build,err=client.CreateWorkspaceBuild(ctx,workspace.ID,startReq)
6464
// It's possible for a workspace build to fail due to the template requiring starting
6565
// workspaces with the active version.
66-
ifcerr,ok:=codersdk.AsError(err);ok&&cerr.StatusCode()==http.StatusUnauthorized {
66+
ifcerr,ok:=codersdk.AsError(err);ok&&cerr.StatusCode()==http.StatusForbidden {
6767
_,_=fmt.Fprintln(inv.Stdout,"Failed to restart with the template version from your last build. Policy may require you to restart with the current active template version.")
6868
build,err=startWorkspace(inv,client,workspace,parameterFlags,WorkspaceUpdate)
6969
iferr!=nil {

‎cli/ssh.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"sync"
1515
"time"
1616

17-
"github.com/coder/retry"
1817
"github.com/gen2brain/beeep"
1918
"github.com/gofrs/flock"
2019
"github.com/google/uuid"
@@ -25,6 +24,8 @@ import (
2524
"golang.org/x/xerrors"
2625
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
2726

27+
"github.com/coder/retry"
28+
2829
"cdr.dev/slog"
2930
"cdr.dev/slog/sloggers/sloghuman"
3031

‎cli/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (r *RootCmd) start() *clibase.Cmd {
3434
build,err:=startWorkspace(inv,client,workspace,parameterFlags,WorkspaceStart)
3535
// It's possible for a workspace build to fail due to the template requiring starting
3636
// workspaces with the active version.
37-
ifcerr,ok:=codersdk.AsError(err);ok&&cerr.StatusCode()==http.StatusUnauthorized {
37+
ifcerr,ok:=codersdk.AsError(err);ok&&cerr.StatusCode()==http.StatusForbidden {
3838
_,_=fmt.Fprintln(inv.Stdout,"Failed to restart with the template version from your last build. Policy may require you to restart with the current active template version.")
3939
build,err=startWorkspace(inv,client,workspace,parameterFlags,WorkspaceUpdate)
4040
iferr!=nil {

‎coderd/workspacebuilds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
379379
ifxerrors.As(err,&buildErr) {
380380
varauthErr dbauthz.NotAuthorizedError
381381
ifxerrors.As(err,&authErr) {
382-
buildErr.Status=http.StatusUnauthorized
382+
buildErr.Status=http.StatusForbidden
383383
}
384384

385385
ifbuildErr.Status==http.StatusInternalServerError {

‎coderd/wsbuilder/wsbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func (b *Builder) buildTx(authFunc func(action rbac.Action, object rbac.Objecter
353353
iferr!=nil {
354354
code:=http.StatusInternalServerError
355355
ifrbac.IsUnauthorizedError(err) {
356-
code=http.StatusUnauthorized
356+
code=http.StatusForbidden
357357
}
358358
returnBuildError{code,"insert workspace build",err}
359359
}

‎enterprise/coderd/workspacebuilds_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func TestWorkspaceBuild(t *testing.T) {
103103
{
104104
Name:"MemberFails",
105105
Client:memberClient,
106-
ExpectedStatusCode:http.StatusUnauthorized,
106+
ExpectedStatusCode:http.StatusForbidden,
107107
},
108108
}
109109

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp