Fix: defensive frontend + panic recovery logging middleware
Frontend: - JobDetail loadLogs: fallback to [] when API returns null - JobDetail loadJob: pairs ?? [] guard on /api/sync-pairs 500 - JobHistory: Array.isArray guard on job list response - api client: return undefined for null body instead of throwing Backend: - handlers_jobs GetLog: return [] instead of null when no log rows - router: custom recoverer middleware that logs panics to slog with full stack trace, method, and path
This commit is contained in:
@@ -166,7 +166,11 @@ func (h *JobHandler) GetLog(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
count, _ := logRepo.CountByJobID(id)
|
||||
w.Header().Set("X-Total-Count", fmt.Sprintf("%d", count))
|
||||
writeJSON(w, logs)
|
||||
if logs == nil {
|
||||
writeJSON(w, []any{})
|
||||
} else {
|
||||
writeJSON(w, logs)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *JobHandler) DownloadLog(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user