Files
noteflow/.claude/hookify.block-datetime-now-fallback.local.md
Travis Vasceannie 1ce24cdf7b feat: reorganize Claude hooks and add RAG documentation structure with error handling policies
- 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
2026-01-15 15:58:06 +00:00

1.3 KiB

name, enabled, event, pattern, action
name enabled event pattern action
block-datetime-now-fallback true file return\s+datetime.now\s*( block

BLOCKED: datetime.now() fallback detected

Returning datetime.now() as a fallback on parse failures causes data corruption.

Why this is dangerous:

  • Silent data corruption - timestamps become incorrect without any error signal
  • Debugging nightmare - no way to trace back to the original parse failure
  • Data integrity loss - downstream consumers receive fabricated timestamps

What to do instead:

  1. Return None and let callers handle missing timestamps explicitly
  2. Raise a typed error (e.g., DateParseError) so failures are visible
  3. Use Result[datetime, ParseError] pattern for explicit error handling

Examples from swallowed.md:

  • _parse_google_datetime returns datetime.now(UTC) on ValueError
  • parse_outlook_datetime returns datetime.now(UTC) on ValueError

Resolution pattern:

# BAD: Silent data corruption
except ValueError:
    logger.warning("Failed to parse: %s", dt_str)
    return datetime.now(UTC)  # Data corruption!

# GOOD: Explicit failure
except ValueError as e:
    raise DateParseError(f"Invalid datetime: {dt_str}") from e

# GOOD: Optional return
except ValueError:
    logger.warning("Failed to parse: %s", dt_str)
    return None  # Caller handles missing timestamp