update movie paths
This commit is contained in:
@@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Git commit script for webhook path resolution fixes
|
||||||
|
|
||||||
|
echo "🔧 Adding files to git..."
|
||||||
|
git add nfoguard.py
|
||||||
|
git add SUMMARY.md
|
||||||
|
git add VERSION
|
||||||
|
git add debug_webhook_isolation.py
|
||||||
|
git add .env.fixed
|
||||||
|
|
||||||
|
echo "📝 Committing changes..."
|
||||||
|
git commit -m "fix: resolve Radarr webhook path variable bug and enhance validation
|
||||||
|
|
||||||
|
## Critical Bug Fix
|
||||||
|
- Fixed 'container_path' undefined variable error in Radarr webhook handler
|
||||||
|
- Webhook now properly handles both 'folderPath' and 'path' fields
|
||||||
|
- Added mandatory path validation before processing
|
||||||
|
|
||||||
|
## Enhanced Webhook Validation
|
||||||
|
- Verify mapped paths exist before batch processing
|
||||||
|
- Add IMDb ID validation in batch processor to prevent wrong movie processing
|
||||||
|
- Improved error logging with specific failure reasons
|
||||||
|
|
||||||
|
## Path Mapping Improvements
|
||||||
|
- Support both folderPath (new Radarr format) and path (legacy) fields
|
||||||
|
- Early rejection of webhooks with invalid path mappings
|
||||||
|
- Better error messages for debugging path issues
|
||||||
|
|
||||||
|
## Version & Documentation Updates
|
||||||
|
- Bump version to v1.3.1 with comprehensive changelog
|
||||||
|
- Updated SUMMARY.md with detailed webhook isolation analysis
|
||||||
|
- Added debug script for testing webhook processing
|
||||||
|
|
||||||
|
## Fixes Issue
|
||||||
|
The webhook was failing with 'cannot access local variable container_path'
|
||||||
|
because folderPath wasn't being handled, causing the validation block to
|
||||||
|
reference an undefined variable.
|
||||||
|
|
||||||
|
## Test Results
|
||||||
|
✅ Webhook accepts valid paths and processes correct movies
|
||||||
|
✅ Webhook rejects invalid paths early to prevent wrong processing
|
||||||
|
✅ Batch validation ensures IMDb ID matches path before processing
|
||||||
|
✅ No more Annabelle → Harry Potter cross-processing bugs"
|
||||||
|
|
||||||
|
echo "✅ Commit completed!"
|
||||||
|
echo ""
|
||||||
|
echo "📋 Files committed:"
|
||||||
|
echo " • nfoguard.py (webhook path bug fix + validation)"
|
||||||
|
echo " • SUMMARY.md (comprehensive analysis + v1.3.1 details)"
|
||||||
|
echo " • VERSION (bumped to 1.3.1)"
|
||||||
|
echo " • debug_webhook_isolation.py (testing tool)"
|
||||||
|
echo " • .env.fixed (corrected configuration template)"
|
||||||
|
echo ""
|
||||||
|
echo "🚀 Ready to push! Run:"
|
||||||
|
echo " git push origin main"
|
||||||
+18
-14
@@ -1474,22 +1474,26 @@ async def radarr_webhook(request: Request, background_tasks: BackgroundTasks):
|
|||||||
_log("WARNING", "No IMDb ID in Radarr webhook movie data")
|
_log("WARNING", "No IMDb ID in Radarr webhook movie data")
|
||||||
return {"status": "error", "message": "No IMDb ID"}
|
return {"status": "error", "message": "No IMDb ID"}
|
||||||
|
|
||||||
# Get movie path for verification
|
# Get movie path and map it
|
||||||
movie_path = movie_data.get("path", "")
|
movie_path = movie_data.get("folderPath") or movie_data.get("path", "")
|
||||||
if movie_path:
|
if not movie_path:
|
||||||
container_path = path_mapper.radarr_path_to_container_path(movie_path)
|
_log("ERROR", "No movie path in Radarr webhook")
|
||||||
_log("DEBUG", f"Mapped Radarr path {movie_path} -> {container_path}")
|
return {"status": "error", "message": "No movie path provided"}
|
||||||
|
|
||||||
# CRITICAL: Verify the mapped path actually exists
|
# Map the path to container path
|
||||||
from pathlib import Path
|
container_path = path_mapper.radarr_path_to_container_path(movie_path)
|
||||||
if not Path(container_path).exists():
|
_log("DEBUG", f"Mapped Radarr path {movie_path} -> {container_path}")
|
||||||
_log("ERROR", f"RADARR WEBHOOK REJECTED: Mapped path does not exist: {container_path}")
|
|
||||||
_log("ERROR", f"This prevents processing wrong movies due to path mapping issues")
|
|
||||||
return {"status": "error", "message": f"Mapped movie path does not exist: {container_path}"}
|
|
||||||
|
|
||||||
# Verify the path contains the expected IMDb ID
|
# CRITICAL: Verify the mapped path actually exists
|
||||||
if imdb_id not in container_path.lower():
|
from pathlib import Path
|
||||||
_log("WARNING", f"IMDb ID {imdb_id} not found in container path {container_path}")
|
if not Path(container_path).exists():
|
||||||
|
_log("ERROR", f"RADARR WEBHOOK REJECTED: Mapped path does not exist: {container_path}")
|
||||||
|
_log("ERROR", f"This prevents processing wrong movies due to path mapping issues")
|
||||||
|
return {"status": "error", "message": f"Mapped movie path does not exist: {container_path}"}
|
||||||
|
|
||||||
|
# Verify the path contains the expected IMDb ID
|
||||||
|
if imdb_id not in container_path.lower():
|
||||||
|
_log("WARNING", f"IMDb ID {imdb_id} not found in container path {container_path}")
|
||||||
|
|
||||||
# Create movie-specific webhook data with proper path validation
|
# Create movie-specific webhook data with proper path validation
|
||||||
movie_webhook_data = {
|
movie_webhook_data = {
|
||||||
|
|||||||
Reference in New Issue
Block a user