Compare commits

...

1 Commits

Author SHA1 Message Date
Ben Potter ed88155b3f fix: add missing return after error response in returnDAUsInternal and fix %n format verbs in tests
Bug 1 (coderd/insights.go:85): returnDAUsInternal writes a 500 error
response when GetTemplateInsightsByInterval fails, but does not return.
Execution falls through to write a second 200 OK response with empty
data. Every other error handler in the same file correctly returns after
writing the error response.

Bug 2 (coderd/database/querier_test.go): Four test assertions use %n as
a format verb for an int argument. %n is not a valid Go fmt verb, so on
assertion failure the row index renders as '%!n(int=X)' instead of the
integer. Changed to %d.
2026-03-04 15:50:58 +00:00
2 changed files with 5 additions and 4 deletions
+4 -4
View File
@@ -4421,7 +4421,7 @@ func TestGetUserStatusCounts(t *testing.T) {
assert.True(
t,
rowDate.Equal(expectedDate),
"expected date %s, but got %s for row %n",
"expected date %s, but got %s for row %d",
expectedDate.String(),
rowDate.String(),
i,
@@ -4594,7 +4594,7 @@ func TestGetUserStatusCounts(t *testing.T) {
require.True(
t,
rowDate.Equal(expectedDate),
"expected date %s, but got %s for row %n",
"expected date %s, but got %s for row %d",
expectedDate.String(),
rowDate.String(),
i,
@@ -4797,7 +4797,7 @@ func TestGetUserStatusCounts(t *testing.T) {
require.True(
t,
row.Date.In(tc.location).Equal(dbtime.StartOfDay(userCreatedAt).AddDate(0, 0, 1+i)),
"expected date %s, but got %s for row %n",
"expected date %s, but got %s for row %d",
dbtime.StartOfDay(userCreatedAt).AddDate(0, 0, 1+i),
row.Date.In(tc.location).String(),
i,
@@ -4864,7 +4864,7 @@ func TestGetUserStatusCounts(t *testing.T) {
assert.True(
t,
row.Date.Equal(target),
"expected date %s, but got %s for row %n",
"expected date %s, but got %s for row %d",
target.String(),
row.Date.String(),
i,
+1
View File
@@ -82,6 +82,7 @@ func (api *API) returnDAUsInternal(rw http.ResponseWriter, r *http.Request, temp
Message: "Internal error fetching DAUs.",
Detail: err.Error(),
})
return
}
resp := codersdk.DAUsResponse{