fix(frontend): use per-instance webhook secret in copy-URL field#293
Conversation
The webhook URL shown in each Arr-instance row was hardcoded to the
master API key:
/api/webhook/<id>?apikey=${apiKeyData?.api_key}
When the instance has a per-instance webhook_secret (the default for
any instance created after the per-instance-secret migration), the
backend rejects requests authenticated with the master API key:
401 Unauthorized {"error":"Invalid webhook secret"}
The user who reported #286 copied the URL verbatim from the Healarr
UI into Sonarr's webhook config and got exactly that rejection.
Fix the per-row URL to prefer arr.webhook_secret over the master
api_key, and revise the Config-page master-key card to call itself
a 'Master API Key' (fallback only) so users don't try to use it
for webhooks on instances that have moved to per-instance secrets.
Closes #286
|
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 (3)
📝 WalkthroughWalkthroughThe PR adds per-instance webhook secret support to Healarr. ChangesPer-Instance Webhook Secret Support
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Possibly related PRs
Poem
✨ 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✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… (#299) 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 Co-authored-by: mescon <mescon@users.noreply.github.com>
Problem
The webhook URL shown in each Arr-instance row was hardcoded to the master API key:
When the instance has a per-instance `webhook_secret` (default for any instance created after the per-instance-secret migration), the backend at `handlers_webhook.go:86-97` rejects requests authenticated with the master key:
#286 reports exactly this: user copied the URL verbatim from the UI into Sonarr's webhook config, Sonarr's connection test failed with the 401.
Fix
Closes #286.
Test plan
Summary by CodeRabbit
New Features
Documentation