Skip to content

Add error handling for audit logs and cache operations#1

Merged
davigiroux merged 1 commit into
mainfrom
claude/fix-evaluate-cache-errors-draCb
Mar 17, 2026
Merged

Add error handling for audit logs and cache operations#1
davigiroux merged 1 commit into
mainfrom
claude/fix-evaluate-cache-errors-draCb

Conversation

@davigiroux

Copy link
Copy Markdown
Owner

Summary

This PR adds proper error handling for audit log insertions and cache operations throughout the flag handler, replacing silent failures with logged errors.

Key Changes

  • Added log import to both flags.go and evaluate.go
  • Wrapped InsertAuditLog() calls in error checks across all flag operations (Create, Update, Delete, Toggle) with contextual logging
  • Wrapped InvalidateFlag() calls in error checks in Update, Delete, and Toggle operations with logging
  • Wrapped GetFlag() and SetFlag() cache operations in the Evaluate handler with error checks and logging
  • All errors are logged with log.Printf() including the operation type and affected flag key for debugging

Implementation Details

  • Errors from audit log operations no longer silently fail; they are logged but don't block the HTTP response
  • Cache errors are similarly logged without blocking the response, allowing graceful degradation
  • Log messages include context about which operation failed (create, update, delete, toggle, cache get/set) and the flag key involved
  • This maintains backward compatibility while improving observability of failures in non-critical operations

https://claude.ai/code/session_01JDqcjWMkkrAyY2CxALpmm3

Previously, cache errors in the evaluate handler were silently discarded
(flag, _ := h.cache.GetFlag), which hid connection errors, serialization
errors, and Redis outages. Similarly, audit log insertion errors in the
flag handler were unchecked, meaning failures from Postgres pressure or
full tables would go unnoticed.

Now all cache and audit log errors are logged via log.Printf so operators
can detect when Redis is unhealthy or audit data is being lost.

https://claude.ai/code/session_01JDqcjWMkkrAyY2CxALpmm3
@davigiroux davigiroux merged commit f87e08e into main Mar 17, 2026
3 checks passed
@davigiroux davigiroux deleted the claude/fix-evaluate-cache-errors-draCb branch March 17, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants