Skip to content

Track rule execution failures for collection media evaluation#2949

Merged
enoch85 merged 6 commits into
developmentfrom
fix-rule-execution-errors
May 22, 2026
Merged

Track rule execution failures for collection media evaluation#2949
enoch85 merged 6 commits into
developmentfrom
fix-rule-execution-errors

Conversation

@SmolSoftBoi

Copy link
Copy Markdown
Collaborator

Summary

  • Add persisted failure tracking for collection media rule evaluation.
  • Update rule execution and collection worker logic to record and surface execution errors more reliably.
  • Extend related entities, interfaces, and test fixtures to match the new failure state.
  • Add coverage for the rule executor and collection worker error paths.

Testing

  • Added and updated unit tests for rule execution and collection worker behaviour.
  • Local validation was not run in this turn.

@SmolSoftBoi SmolSoftBoi added the bug Something isn't working label May 21, 2026
@SmolSoftBoi SmolSoftBoi marked this pull request as ready for review May 21, 2026 21:12
@SmolSoftBoi SmolSoftBoi requested a review from enoch85 as a code owner May 21, 2026 21:12
Copilot AI review requested due to automatic review settings May 21, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds persisted tracking for rule-evaluation failures on collection_media records, then uses that state to (a) prevent rule-driven removals when evaluation data was transiently unavailable and (b) prevent the collection worker from acting on media that’s in a failed-evaluation state.

Changes:

  • Add ruleEvaluationFailed boolean to CollectionMedia, plus a migration and updated test fixtures.
  • Update RuleExecutorService to persist/clear failure flags when transient evaluation failures occur and later recover.
  • Update CollectionWorkerService and unit tests to skip handling media flagged with ruleEvaluationFailed.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/server/test/utils/data.ts Updates createCollectionMedia fixture to include ruleEvaluationFailed.
apps/server/src/modules/rules/tasks/rule-executor.service.ts Persists transient rule evaluation failure state and clears it on recovery.
apps/server/src/modules/rules/tasks/rule-executor.service.spec.ts Adds/updates tests for transient failure preservation and flag clearing.
apps/server/src/modules/rules/entities/rule-group.entities.ts Makes dataType column type explicit (varchar).
apps/server/src/modules/rules/entities/exclusion.entities.ts Makes type column type explicit (varchar).
apps/server/src/modules/logging/entities/logSettings.entities.ts Makes level column type explicit (varchar).
apps/server/src/modules/collections/interfaces/collection-media.interface.ts Extends CollectionMediaRecord with ruleEvaluationFailed.
apps/server/src/modules/collections/entities/collection.entities.ts Makes type column type explicit (varchar).
apps/server/src/modules/collections/entities/collection_media.entities.ts Adds persisted ruleEvaluationFailed column.
apps/server/src/modules/collections/entities/collection_log.entities.ts Makes type column type explicit (integer).
apps/server/src/modules/collections/collections.service.ts Adds setCollectionMediaRuleEvaluationFailed + initializes new records with false.
apps/server/src/modules/collections/collection-worker.service.ts Skips due media that has ruleEvaluationFailed: true.
apps/server/src/modules/collections/collection-worker.server.spec.ts Updates worker spec to assert ruleEvaluationFailed: false filtering.
apps/server/src/database/migrations/1779215202958-AddCollectionMediaRuleEvaluationFailed.ts Adds DB column with default + table rebuild migration for SQLite.

Comment thread apps/server/src/modules/rules/tasks/rule-executor.service.ts Outdated
Comment thread apps/server/src/modules/collections/collection-worker.service.ts Outdated
@enoch85

enoch85 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

@SmolSoftBoi Thanks!

Did you test this end to end?

Comment thread apps/server/src/modules/collections/collection-worker.service.ts Outdated
enoch85 added 2 commits May 22, 2026 19:33
…tracking

- collection-worker.server.spec: drop mock for non-existent
  SettingsDataService.testConnections (failed check-types CI)
- collection-worker: keep original mediaToHandle naming, apply the
  ruleEvaluationFailed filter inline (per review feedback)
- collections.service: make setCollectionMediaRuleEvaluationFailed
  best-effort so a failed flag write can't abort the rule run
@enoch85

enoch85 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

@SmolSoftBoi Good job on this! Super clean, tight and minimal. 🎉

@enoch85 enoch85 merged commit 4d925d3 into development May 22, 2026
14 checks passed
@enoch85 enoch85 deleted the fix-rule-execution-errors branch May 22, 2026 17:52
@maintainerr-automation

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.12.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@enoch85 enoch85 added this to the 3.12.1 milestone May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors within rule execution for existing collection items could be handled better

3 participants