Skip to content

Validate ignored_referencing_fields configuration and add tests#1

Merged
SupraSummus merged 1 commit into
mainfrom
claude/quirky-meitner-vzfwws
Jun 10, 2026
Merged

Validate ignored_referencing_fields configuration and add tests#1
SupraSummus merged 1 commit into
mainfrom
claude/quirky-meitner-vzfwws

Conversation

@SupraSummus

Copy link
Copy Markdown
Member

Summary

This PR adds validation to the garbage collection command to ensure that configured ignored_referencing_fields actually match existing ForeignKey fields. It also includes comprehensive tests and documentation updates.

Key Changes

  • Configuration Validation: The find_fk_fields() function now tracks which ignored field paths are actually matched against existing ForeignKeys. If any configured paths don't match, a CommandError is raised with a clear message about the stale or incorrect configuration.
  • Test Coverage: Added two new test cases:
    • test_ignored_referencing_field_does_not_keep_row_alive(): Verifies that ignored referencing fields don't prevent garbage collection
    • test_unmatched_ignored_field_path_fails_loudly(): Ensures the command fails with a helpful error message when configuration contains invalid field paths
  • Model Updates: Added Cache and CacheLog test models to support the new test cases
  • Documentation: Updated README to clarify that invalid field paths in gc_ignored_referencing_fields will cause the command to fail, catching configuration errors early

Implementation Details

  • The validation happens in find_fk_fields() by maintaining a matched_ignored set that tracks which ignored paths were successfully matched
  • Unmatched paths are detected and reported before the function returns, ensuring errors are caught even in dry-run mode
  • The error message is descriptive and suggests the issue is either stale configuration or a typo

https://claude.ai/code/session_01NWap56ibZN8sey8mQfa8uw

The command used to silently skip ignore paths that did not match any
FK pointing at the target model, so a typo or a stale path (e.g. after
a model moved to another app) quietly changed collection behavior.
Validate every configured path on each run, dry runs included.

https://claude.ai/code/session_01NWap56ibZN8sey8mQfa8uw
@SupraSummus
SupraSummus force-pushed the claude/quirky-meitner-vzfwws branch from 4fffc10 to dec980b Compare June 10, 2026 06:22
@SupraSummus
SupraSummus merged commit 1922477 into main Jun 10, 2026
3 checks passed
@SupraSummus
SupraSummus deleted the claude/quirky-meitner-vzfwws branch June 10, 2026 06:23
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.

1 participant