Skip to content

Commit 3535048

Browse files
committed
Use 404 instead of 403 for disabled endpoint
1 parent be20e54 commit 3535048

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,8 @@ func New(options *Options) *API {
15341534
func(next http.Handler) http.Handler {
15351535
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
15361536
if !options.DeploymentValues.TemplateInsights.Enable.Value() {
1537-
httpapi.Write(context.Background(), rw, http.StatusForbidden, codersdk.Response{
1538-
Message: "Forbidden.",
1537+
httpapi.Write(context.Background(), rw, http.StatusNotFound, codersdk.Response{
1538+
Message: "Not Found.",
15391539
Detail: "Template insights are disabled.",
15401540
})
15411541
return

coderd/insights_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,8 +2418,8 @@ func TestGenericInsights_Disabled(t *testing.T) {
24182418
tests := []struct {
24192419
name string
24202420
fn func(ctx context.Context) error
2421-
// ok means there should be no error, otherwise assume forbidden due to
2422-
// being disabled.
2421+
// ok means there should be no error, otherwise assume 404 due to being
2422+
// disabled.
24232423
ok bool
24242424
}{
24252425
{
@@ -2478,7 +2478,7 @@ func TestGenericInsights_Disabled(t *testing.T) {
24782478
require.Error(t, err)
24792479
cerr := coderdtest.SDKError(t, err)
24802480
require.Contains(t, cerr.Error(), "disabled")
2481-
require.Equal(t, http.StatusForbidden, cerr.StatusCode())
2481+
require.Equal(t, http.StatusNotFound, cerr.StatusCode())
24822482
}
24832483
})
24842484
}

site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.stories.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ export const Loading: Story = {
2929
},
3030
};
3131

32-
const forbidden = mockApiError({
33-
message: "Forbidden.",
32+
const notFound = mockApiError({
33+
message: "Not Found.",
3434
detail: "Template insights are disabled.",
3535
});
3636

3737
export const LoadingError: Story = {
3838
args: {
3939
templateInsights: {
4040
data: undefined,
41-
error: forbidden,
41+
error: notFound,
4242
},
4343
userLatency: {
4444
data: undefined,
45-
error: forbidden,
45+
error: notFound,
4646
},
4747
userActivity: {
4848
data: undefined,
49-
error: forbidden,
49+
error: notFound,
5050
},
5151
},
5252
};

0 commit comments

Comments
 (0)