- Moved all hookify configuration files from `.claude/` to `.claude/hooks/` subdirectory for better organization - Added four new blocking hooks to prevent common error handling anti-patterns: - `block-broad-exception-handler`: Prevents catching generic `Exception` with only logging - `block-datetime-now-fallback`: Blocks returning `datetime.now()` as fallback on parse failures to prevent data corruption - `block-default
2.1 KiB
2.1 KiB
name, enabled, event, conditions, action
| name | enabled | event | conditions | action | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| block-default-value-swallow | true | file |
|
block |
BLOCKED: Default value swallowing on config/settings failure
Returning hardcoded defaults when configuration loading fails hides critical initialization errors.
Why this is dangerous:
- Application runs with unexpected/incorrect configuration
- Users have no idea their settings aren't being applied
- Subtle bugs that only manifest under specific conditions
- Security settings might be weaker than intended
Examples from swallowed.md:
get_llm_settingsreturns hardcoded defaults on any exception_get_ollama_settingsreturns defaults on settings load failureget_webhook_settingsreturns defaults on exceptiondiarization_job_ttl_secondsreturns default TTL on failure
What to do instead:
- Fail fast at startup - validate config before accepting requests
- Return typed errors - let callers decide how to handle missing config
- Mark degraded mode - if defaulting is acceptable, make it visible
Resolution pattern:
# BAD: Silent defaulting
except Exception as exc:
logger.warning("Settings load failed, using defaults")
return HardcodedDefaults() # User has no idea!
# GOOD: Fail fast
except Exception as exc:
raise ConfigurationError(f"Failed to load settings: {exc}") from exc
# GOOD: Explicit degraded mode (if truly acceptable)
except Exception as exc:
logger.error("config_degraded_mode", error=str(exc))
metrics.set_gauge("config_degraded", 1) # Observable!
return DefaultSettings(degraded=True) # Callers can check
Startup validation pattern:
# Validate config at startup, not on every call
def validate_config_or_fail():
try:
settings = load_settings()
settings.validate()
except Exception as e:
sys.exit(f"Configuration error: {e}")