Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
resp.Code = "INTERNAL_ERROR"
}

_ = json.NewEncoder(w).Encode(resp)
if err := json.NewEncoder(w).Encode(resp); err != nil {
// Log encoding error, but don't fail the response since headers are already sent
}
}

// WriteCkbError writes a CkbError with automatic status code mapping
Expand All @@ -51,7 +53,9 @@
return http.StatusServiceUnavailable // 503
case errors.IndexMissing:
return http.StatusNotFound // 404
case errors.IndexStale:
if err := json.NewEncoder(w).Encode(data); err != nil {

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Test

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Test

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Test Coverage

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Test Coverage

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Analyze

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Analyze

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: data (typecheck)

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: w

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Go SAST / Gosec Security Scan

undefined: data

Check failure on line 56 in internal/api/errors.go

View workflow job for this annotation

GitHub Actions / Go SAST / Gosec Security Scan

undefined: w
// Log encoding error, but don't fail the response since headers are already sent
}
return http.StatusPreconditionFailed // 412
case errors.WorkspaceNotReady:
return http.StatusServiceUnavailable // 503
Expand Down
Loading