Problem
12+ instances of "failed to load ... for UI" logging are scattered across 9 handler files with inconsistent APIs:
Inconsistent logging calls
| File |
Line |
API used |
ui_sources.go |
155 |
h.logger().ErrorContext(ctx, ...) |
ui_sites.go |
137 |
h.logger().Error(...) (no ctx) |
ui_iocs.go |
76 |
h.logger().ErrorContext(ctx, ...) |
ui_jobs.go |
1253 |
h.logger().ErrorContext(ctx, ...) |
ui_secrets.go |
33 |
h.logger().Error(...) (no ctx) |
ui_alerts.go |
129, 158, 219 |
h.logger().ErrorContext(ctx, ...) |
ui_dashboard.go |
264 |
h.logger().Error(...) (no ctx) |
ui_alert_sinks.go |
63, 97 |
h.logger().Error(...) / h.logger().Warn(...) |
ui_allowlist.go |
23 |
h.logger().Error(...) (no ctx) |
Some use ErrorContext(ctx, ...) with structured context, others fall back to Error(...) without the request context — making traceability inconsistent.
Impact
- Telemetry gap: Without ctx, logs lack request tracing metadata (request ID, correlation ID).
- Inconsistent UX: Some errors render via
RenderError, others use raw http.Error(w, ...).
- HTMX awareness missing: Error responses don't consistently account for HTMX partial vs full-page requests.
Proposed fix
Expand the existing error_renderer.go / RenderError to cover list handler errors:
// LogAndRenderListError logs a structured error and renders an appropriate response.
func LogAndRenderListError(
ctx context.Context, logger *slog.Logger, w http.ResponseWriter, r *http.Request,
err error, msg string, basePath string, pageMeta PageMeta,
) {
logger.ErrorContext(ctx, msg, "error", err)
RenderError(ctx, w, r, err, basePath, pageMeta)
}
Replace all 12+ instances with a single call. Standardize on ErrorContext everywhere.
Files to change
services/merrymaker-go/internal/http/error_renderer.go — expand helpers
- All 9 handler files listed above
Acceptance criteria
- All error logging uses
ErrorContext(ctx, ...) consistently
- Single helper in
error_renderer.go handles log + render for list errors
- No behavior change to end users' error experience
- Lint + tests pass
Problem
12+ instances of
"failed to load ... for UI"logging are scattered across 9 handler files with inconsistent APIs:Inconsistent logging calls
ui_sources.goh.logger().ErrorContext(ctx, ...)ui_sites.goh.logger().Error(...)(no ctx)ui_iocs.goh.logger().ErrorContext(ctx, ...)ui_jobs.goh.logger().ErrorContext(ctx, ...)ui_secrets.goh.logger().Error(...)(no ctx)ui_alerts.goh.logger().ErrorContext(ctx, ...)ui_dashboard.goh.logger().Error(...)(no ctx)ui_alert_sinks.goh.logger().Error(...)/h.logger().Warn(...)ui_allowlist.goh.logger().Error(...)(no ctx)Some use
ErrorContext(ctx, ...)with structured context, others fall back toError(...)without the request context — making traceability inconsistent.Impact
RenderError, others use rawhttp.Error(w, ...).Proposed fix
Expand the existing
error_renderer.go/RenderErrorto cover list handler errors:Replace all 12+ instances with a single call. Standardize on
ErrorContexteverywhere.Files to change
services/merrymaker-go/internal/http/error_renderer.go— expand helpersAcceptance criteria
ErrorContext(ctx, ...)consistentlyerror_renderer.gohandles log + render for list errors