Skip to content

Commit aec49c5

Browse files
committed
Catch broader set of conditions in the if statement
1 parent 227e1c5 commit aec49c5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

coderd/workspaceapps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (api *API) workspaceAppsProxyPath(rw http.ResponseWriter, r *http.Request)
8080
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
8181
Message: "No agents exist.",
8282
})
83+
return
8384
}
8485

8586
agent := agents[0]

scripts/rules.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,19 @@ func HttpAPIReturn(m dsl.Matcher) {
159159
// Manually enumerate the httpapi function rather then a 'Where' condition
160160
// as this is a bit more efficient.
161161
m.Match(`
162-
if err != nil {
163-
httpapi.Write($*_)
162+
if $*_ {
163+
httpapi.Write($*a)
164164
}
165165
`, `
166-
if err != nil {
167-
httpapi.Forbidden($*_)
166+
if $*_ {
167+
httpapi.Forbidden($*a)
168168
}
169169
`, `
170-
if err != nil {
171-
httpapi.ResourceNotFound($*_)
170+
if $*_ {
171+
httpapi.ResourceNotFound($*a)
172172
}
173-
`).Report("Forgot to return early after the httpapi.Write call")
173+
`).At(m["a"]).
174+
Report("Forgot to return early after the httpapi.Write call")
174175
}
175176

176177
// ProperRBACReturn ensures we always write to the response writer after a

0 commit comments

Comments
 (0)