Skip to content

Commit 8c23f70

Browse files
committed
mimic http response writer default status 200
1 parent 6ac7b30 commit 8c23f70

File tree

1 file changed

+9
-2
lines changed
  • coderd/workspaceapps

1 file changed

+9
-2
lines changed

coderd/workspaceapps/db.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ func (p *DBTokenProvider) auditInitAutocommitRequest(ctx context.Context, w http
493493
}
494494
}
495495

496+
// Mimic the behavior of a HTTP status writer
497+
// by defaulting to 200 if the status is 0.
498+
status := sw.Status
499+
if status == 0 {
500+
status = http.StatusOK
501+
}
502+
496503
// We use the background audit function instead of init request
497504
// here because we don't know the resource type ahead of time.
498505
// This also allows us to log unauthenticated access.
@@ -508,7 +515,7 @@ func (p *DBTokenProvider) auditInitAutocommitRequest(ctx context.Context, w http
508515
UserID: userID.UUID,
509516
RequestID: sessionID,
510517
Time: aReq.time,
511-
Status: sw.Status,
518+
Status: status,
512519
IP: aReq.ip.IPNet.IP.String(),
513520
UserAgent: r.UserAgent(),
514521
New: aReq.dbReq.App,
@@ -525,7 +532,7 @@ func (p *DBTokenProvider) auditInitAutocommitRequest(ctx context.Context, w http
525532
UserID: userID.UUID,
526533
RequestID: sessionID,
527534
Time: aReq.time,
528-
Status: sw.Status,
535+
Status: status,
529536
IP: aReq.ip.IPNet.IP.String(),
530537
UserAgent: r.UserAgent(),
531538
New: aReq.dbReq.Agent,

0 commit comments

Comments
 (0)