From feee1dffde303db1ede47087f1964deca4e553f0 Mon Sep 17 00:00:00 2001 From: 5ymb01 <5ymb01ixm@gmail.com> Date: Sun, 8 Mar 2026 20:38:04 -0400 Subject: [PATCH] fix(web): remove shadowed sys import in plugin action handler (#280) * fix(web): remove shadowed sys import in plugin action handler Two `import sys` statements inside execute_plugin_action() and authenticate_spotify() shadowed the module-level import, causing "cannot access local variable 'sys'" errors when sys.executable was referenced in earlier branches of the same function. Also fixes day number validation in the of-the-day upload endpoint to accept 366 (leap year). Co-Authored-By: Claude Opus 4.6 * fix(api): correct validation message from 1-365 to 1-366 The JSON structure validation message still said '1-365' while the actual range check accepts 1-366 for leap years. Make all three validation messages consistent. Addresses CodeRabbit finding on PR #280. Co-Authored-By: 5ymb01 <5ymb01@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: 5ymb01 <5ymb01@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 --- web_interface/blueprints/api_v3.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web_interface/blueprints/api_v3.py b/web_interface/blueprints/api_v3.py index c49afc24..ecd77f38 100644 --- a/web_interface/blueprints/api_v3.py +++ b/web_interface/blueprints/api_v3.py @@ -5251,7 +5251,6 @@ sys.exit(proc.returncode) # For OAuth flows, we might need to import the script as a module if action_def.get('oauth_flow'): # Import script as module to get auth URL - import sys import importlib.util spec = importlib.util.spec_from_file_location("plugin_action", script_file) @@ -5442,7 +5441,6 @@ sys.exit(proc.returncode) else: # Step 1: Get authorization URL # Import the script's functions directly to get the auth URL - import sys import importlib.util # Load the authentication script as a module @@ -6209,22 +6207,22 @@ def upload_of_the_day_json(): if not isinstance(json_data, dict): return jsonify({ 'status': 'error', - 'message': f'JSON in {file.filename} must be an object with day numbers (1-365) as keys' + 'message': f'JSON in {file.filename} must be an object with day numbers (1-366) as keys' }), 400 # Check if keys are valid day numbers for key in json_data.keys(): try: day_num = int(key) - if day_num < 1 or day_num > 365: + if day_num < 1 or day_num > 366: return jsonify({ 'status': 'error', - 'message': f'Day number {day_num} in {file.filename} is out of range (must be 1-365)' + 'message': f'Day number {day_num} in {file.filename} is out of range (must be 1-366)' }), 400 except ValueError: return jsonify({ 'status': 'error', - 'message': f'Invalid key "{key}" in {file.filename}: must be a day number (1-365)' + 'message': f'Invalid key "{key}" in {file.filename}: must be a day number (1-366)' }), 400 # Generate safe filename from original (preserve user's filename)