fix: log swallowed exceptions in core server components#1023
fix: log swallowed exceptions in core server components#1023GonzoSpire merged 3 commits intomasterfrom
Conversation
Three silent catch blocks were hiding errors with no diagnostic info: - TreeValuesCache.MigrateDatabaseV2: log sensorId when value deserialization fails during V2 migration instead of silently skipping the record - AlertScheduleProvider.LoadSchedulesFromDb: log parse error and entity id/name when schedule parsing fails and fallback to raw entity is used - TreeStateSnapshot ctor: add NLog logger and log deserialization error when state snapshot fails to load, instead of silently setting HasData=false Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Review: fix/log-swallowed-exceptionsOverall assessment: Clean, focused, and correct fix. The three What's good
IssuesMinor — Logger style inconsistency
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();But private readonly Logger _logger = LogManager.GetLogger(nameof(TreeValuesCache));And Minor —
|
| Category | Finding | Severity |
|---|---|---|
| Logger style | Inconsistent static vs instance field across three files |
Nit |
using order |
System and NLog usings out of conventional order |
Nit |
| Pre-existing | Fallback in AlertScheduleProvider can throw again on bad entity.Id |
Follow-up |
No blockers. Approve with the above nits noted.
…atabaseV2 AlertScheduleProvider: skip unparseable schedules instead of adding them to cache as broken objects. A partially-constructed AlertSchedule with no parsed working hours has unpredictable IsWorkingTime behavior - skipping is safer than a fallback that silently misfires alerts. TreeValuesCache.MigrateDatabaseV2: add success/failed counters and log migration summary so data loss during migration is visible in logs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Review: fix/log-swallowed-exceptionsOverall direction is correct — silently swallowed exceptions are genuinely harmful for observability. However there are a few issues worth addressing before merging. 1. Breaking behavioral change in
|
| Severity | File | Issue |
|---|---|---|
| Medium | AlertScheduleProvider.cs |
Fallback silently removed — schedules now dropped on parse error instead of degraded-but-loaded |
| Low | TreeValuesCache.cs |
success counter over-counts (includes expired/not-stored records); null-sensor records unaccounted |
| Nit | TreeStateSnapshot.cs |
Log message may be slightly misleading |
The logging additions themselves are the right call. The TreeStateSnapshot change is clean. The main concern is the AlertScheduleProvider behavioral change which could manifest as missing alert schedules in production.
PR Review: fix/log-swallowed-exceptionsOverall direction is correct — silent Bug:
|
Summary
Three
catchblocks in the server core were silently swallowing exceptions with no logging, making production issues impossible to diagnose.MigrateDatabaseV2: logssensorId+ exception when value deserialization fails, instead of silentlycontinue-ingLoadSchedulesFromDb: logs parse error with scheduleId/Namewhen_parser.Parse()throws, before falling back to raw entityHasData = falseImpact
Previously these failures were completely invisible in logs. Now operators can see exactly which sensors/schedules are corrupted and investigate.
🤖 Generated with Claude Code