fix(integration): match Windows UNC paths in webhook path mapper#299
Conversation
The path-matching logic between *arr-reported paths and configured scan paths required the post-prefix remainder to begin with a forward slash. On Windows, Sonarr/Radarr report paths verbatim with UNC roots and backslash separators, e.g.: \\alexpr4100\\media\\Movies\\High Strung (2016)\\film.mkv With a scan path configured as \\alexpr4100\\media\\Movies, the HasPrefix match succeeded but the remainder validation (which only accepted '/') rejected the match. Every Windows-hosted setup got: Webhook path mapping failed: *arr reported path '...' but no matching scan path found even with a correctly configured scan path. Fix: accept either / or \\ as the directory-boundary separator after a prefix match, and strip either as a trailing separator at load time. Helpers are factored out (pathSeparators, hasSepPrefix, trimTrailingSep) so the rule is named once and applied consistently across Reload / ToArrPath / ToLocalPath. Reported by alex882001 in #298. The earlier per-instance webhook secret fix (#293, v1.3.6) was a prerequisite for this report — without it the request would have been rejected at the auth gate before ever reaching path mapping. Closes #298
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPath mapper logic is enhanced to recognize Windows UNC paths by supporting both forward and backslash separators in prefix matching and canonicalization. Helper functions normalize trailing separators while preserving UNC anchors, and conversion methods now validate directory boundaries using either separator type. ChangesWindows UNC Path Mapping
🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Closes #298.
Problem
The path matcher (`internal/integration/path_mapper.go`) required the post-prefix remainder to start with a forward slash, so Windows UNC paths reported by *arr never matched. Every Healarr-on-Docker-Desktop-Windows setup hit:
even with a correctly configured scan path `\\alexpr4100\media\Movies`. Reported by @alex882001 in #298 after the v1.3.6 webhook-auth fix (#293) let his request reach the mapper layer in the first place.
Fix
Accept either `/` or `\\` as the directory-boundary separator in:
Helpers factored out (`pathSeparators`, `hasSepPrefix`, `trimTrailingSep`) so the rule is named once.
Test plan
Caveats
This fix gets the path matching working. If the user is running Healarr in a Linux container (Docker Desktop default) and their UNC share isn't mounted into the container, scanning will still fail at file-access time — that's a deployment issue, not a code one. The error message in that case will be from the scanner ("file not accessible"), which is at least a useful signal pointing at the real problem rather than the misleading "no matching scan path".
Summary by CodeRabbit
Bug Fixes
Tests