Repository navigation
fix(autoscan): advance marker past paths outside any library folder - #314
Conversation
A filesystem-watcher scan source (e.g. the CephFS plugin) observes the entire volume, so it legitimately returns changes for paths that live in folders which are not registered as Silo libraries (unregistered decade buckets, 4k-dv, anime-dub, download/recycle dirs, etc.). Previously, when a poll returned paths but none resolved to a library folder, PollOnce recorded an "unresolved" error and refused to advance the marker, on the assumption this only happens for a freshly-enabled source with unconfigured path rewrites. For a whole-volume watcher that assumption is wrong: a single change under an unregistered folder pins the journal marker in place, so every subsequent poll re-reads the same window and autoscan stalls permanently. Real imports pile up behind the stuck marker and are never scanned until the next full library scan. Treat "paths returned but none resolved" as a benign, expected condition: log a warning (so an operator can still investigate a genuinely misconfigured source) and advance the marker so the queue keeps moving. Partial resolution was already handled correctly — the unresolved subset is simply outside Silo's libraries. Observed in production: one file added under movies/4k-dv (not a library path) froze the CephFS source for ~18 days; ~42k journal changes had accumulated behind it. With this change the marker advances and the backlog drains on the next poll.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAutoscan now advances the marker when returned paths do not match any Silo library, unless resolution encounters transient internal failures. Event completion, marker handling, and test coverage were updated to reflect the two outcomes. ChangesMarker advancement on unresolved autoscan results
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Provider
participant Service
participant Store
Provider->>Service: return changes
Service->>Service: resolve paths and count transient errors
alt transient internal errors occurred
Service->>Store: finish event (EventStatusError)
Service->>Service: keep marker
else paths matched no Silo library folder
Service->>Store: finish event (EventStatusUnresolved)
Service->>Store: advance marker
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cac98e72a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if len(changes) > 0 && !resolvedAny { | ||
| msg := fmt.Sprintf("returned %d path(s) but none matched a Silo library folder — check this source's path rewrites", len(changes)) | ||
| if rerr := s.store.RecordError(ctx, src.ID, msg); rerr != nil { | ||
| slog.WarnContext(ctx, "autoscan: record error failed", "source_id", src.ID, "err", rerr) | ||
| } | ||
| s.finishEvent(ctx, eventID, EventFinish{ | ||
| Status: EventStatusUnresolved, | ||
| ChangesReturned: len(changes), | ||
| ErrorMessage: msg, | ||
| MarkerAfter: marker, | ||
| }) | ||
| continue // do NOT advance marker | ||
| slog.WarnContext(ctx, "autoscan: returned paths matched no library folder — advancing marker", | ||
| "source_id", src.ID, "changes", len(changes)) |
There was a problem hiding this comment.
Keep markers when connection-backed sources resolve nothing
This branch now advances the marker for every source whose returned paths fail to resolve, but that case is still a setup/error signal for Sonarr/Radarr-style sources with missing or wrong path_rewrites. In that scenario the provider has returned real imported media paths, no scans are enqueued, and the following AdvanceMarker consumes the provider marker and clears last_error, so the same imports will not be retried after the operator fixes the rewrite. Please limit the benign advance to known whole-volume filesystem watchers, or keep the marker for connection-backed sources when none of the returned paths map to a library.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/autoscan/service.go (1)
242-255: 🩺 Stability & Availability | 🔵 Trivial | ⚖️ Poor tradeoffConsider surfacing repeated unresolved-paths warnings for operators.
Logic correctly matches the PR intent: warn and advance instead of stalling. One gap: since no error is recorded anymore, persistent misconfiguration (e.g., a bad path-rewrite rule silently causing every path to miss resolution) will now only show up in logs, with events reporting
EventStatusSuccessindefinitely. Consider tracking a metric/counter or surfacing "N consecutive unresolved polls" so operators can still notice a persistently misconfigured source, without reverting to hard error state.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/autoscan/service.go` around lines 242 - 255, The autoscan warning in the unresolved-paths branch now advances correctly, but persistent unresolved polls are only logged and never surfaced elsewhere. Update the autoscan flow around the changes/resolvedAny check in service.go to track repeated unresolved polls for a source, such as a counter for consecutive unresolved scans or a metric on the warning path. Keep the existing warning-and-advance behavior, but add operator-visible telemetry so a misconfigured source can still be detected even when EventStatusSuccess is reported.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/autoscan/service.go`:
- Around line 242-255: The autoscan warning in the unresolved-paths branch now
advances correctly, but persistent unresolved polls are only logged and never
surfaced elsewhere. Update the autoscan flow around the changes/resolvedAny
check in service.go to track repeated unresolved polls for a source, such as a
counter for consecutive unresolved scans or a metric on the warning path. Keep
the existing warning-and-advance behavior, but add operator-visible telemetry so
a misconfigured source can still be detected even when EventStatusSuccess is
reported.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cacb6b94-9efe-4846-be20-8df6302fffda
📒 Files selected for processing (2)
internal/autoscan/service.gointernal/autoscan/service_test.go
…lved events visible Review follow-up: advancing past a window where nothing resolved is only safe when every path is genuinely outside Silo's libraries (RequestError). When resolve attempts fail internally (resolver/database fault), the same resolvedAny=false state now holds the marker and records the error so the window is retried once the fault clears, instead of silently skipping imports until the next full library scan. The benign outside-libraries case still advances, but finishes its poll event as "unresolved" (with an explaining message) instead of "success", so the condition stays visible in poll history and the existing unresolved status filter in the API/admin UI keeps working. Stale doc comments on PollOnce and AdvanceMarker updated to match the new behavior. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Maintainer follow-up pushed in 730b880 after review. The stall diagnosis and the direction here are right — thanks for the detailed writeup. Two things the flat "always advance" flip gave up, now restored: 1. Transient resolver failures no longer advance the marker. 2. The all-outside case stays observable. It still advances (the fix this PR is for), but the poll event now finishes as Also refreshed the stale doc comments on AI-use disclosure: review and follow-up commit were done with Claude Code (Claude Fable 5), maintainer-verified; |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/autoscan/service.go`:
- Around line 266-278: The autoscan marker advance logic in autoscan/service.go
only holds the marker when no paths were resolved, so mixed results can still
advance past a transient failure. Update the event handling branch around the
existing `stats.TransientErrors` and `resolvedAny` checks in `service.go` so any
internal resolve failure keeps the current marker and records the error before
advancing. Use the existing `RecordError`, `finishEvent`, and `AdvanceMarker`
flow to ensure the mixed resolved + transient-failed case does not skip the
failed path, and add a regression test for that scenario.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1cb33fa8-dd2d-4e3d-9e49-61464fd6b70e
📒 Files selected for processing (3)
internal/autoscan/repository.gointernal/autoscan/service.gointernal/autoscan/service_test.go
✅ Files skipped from review due to trivial changes (1)
- internal/autoscan/repository.go
…, not only when all do The transient-failure hold was gated inside the nothing-resolved branch, so a mixed window (some paths resolved+enqueued, others failed on an internal resolver fault) still advanced the marker past the failed paths. Hoist the gate: any internal resolve failure now records the error and holds the marker regardless of how many paths resolved. The resolved targets were already enqueued; re-reading the window at worst re-scans them, which is safe. Adds a mixed-window regression test. Co-Authored-By: Claude Fable 5 <[email protected]>
…314) * fix(autoscan): advance marker past paths outside any library folder A filesystem-watcher scan source (e.g. the CephFS plugin) observes the entire volume, so it legitimately returns changes for paths that live in folders which are not registered as Silo libraries (unregistered decade buckets, 4k-dv, anime-dub, download/recycle dirs, etc.). Previously, when a poll returned paths but none resolved to a library folder, PollOnce recorded an "unresolved" error and refused to advance the marker, on the assumption this only happens for a freshly-enabled source with unconfigured path rewrites. For a whole-volume watcher that assumption is wrong: a single change under an unregistered folder pins the journal marker in place, so every subsequent poll re-reads the same window and autoscan stalls permanently. Real imports pile up behind the stuck marker and are never scanned until the next full library scan. Treat "paths returned but none resolved" as a benign, expected condition: log a warning (so an operator can still investigate a genuinely misconfigured source) and advance the marker so the queue keeps moving. Partial resolution was already handled correctly — the unresolved subset is simply outside Silo's libraries. Observed in production: one file added under movies/4k-dv (not a library path) froze the CephFS source for ~18 days; ~42k journal changes had accumulated behind it. With this change the marker advances and the backlog drains on the next poll. * fix(autoscan): hold marker on transient resolve failures, keep unresolved events visible Review follow-up: advancing past a window where nothing resolved is only safe when every path is genuinely outside Silo's libraries (RequestError). When resolve attempts fail internally (resolver/database fault), the same resolvedAny=false state now holds the marker and records the error so the window is retried once the fault clears, instead of silently skipping imports until the next full library scan. The benign outside-libraries case still advances, but finishes its poll event as "unresolved" (with an explaining message) instead of "success", so the condition stays visible in poll history and the existing unresolved status filter in the API/admin UI keeps working. Stale doc comments on PollOnce and AdvanceMarker updated to match the new behavior. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(autoscan): hold marker when any resolve attempt fails transiently, not only when all do The transient-failure hold was gated inside the nothing-resolved branch, so a mixed window (some paths resolved+enqueued, others failed on an internal resolver fault) still advanced the marker past the failed paths. Hoist the gate: any internal resolve failure now records the error and holds the marker regardless of how many paths resolved. The resolved targets were already enqueued; re-reading the window at worst re-scans them, which is safe. Adds a mixed-window regression test. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Quick <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
A filesystem-watcher scan source (e.g. the CephFS plugin) observes the entire volume, so it legitimately returns changes for paths that live in folders which are not registered as Silo libraries (unregistered decade buckets, 4k-dv, anime-dub, download/recycle dirs, etc.).
Previously, when a poll returned paths but none resolved to a library folder, PollOnce recorded an "unresolved" error and refused to advance the marker, on the assumption this only happens for a freshly-enabled source with unconfigured path rewrites. For a whole-volume watcher that assumption is wrong: a single change under an unregistered folder pins the journal marker in place, so every subsequent poll re-reads the same window and autoscan stalls permanently. Real imports pile up behind the stuck marker and are never scanned until the next full library scan.
Treat "paths returned but none resolved" as a benign, expected condition: log a warning (so an operator can still investigate a genuinely misconfigured source) and advance the marker so the queue keeps moving. Partial resolution was already handled correctly — the unresolved subset is simply outside Silo's libraries.
Observed in production: one file added under movies/4k-dv (not a library path) froze the CephFS source for ~18 days; ~42k journal changes had accumulated behind it. With this change the marker advances and the backlog drains on the next poll.
Summary by CodeRabbit