parkpow / deep-license-plate-recognition

Automatic License Plate Recognition (ALPR) or Automatic Number Plate Recognition (ANPR) software that works with any camera.
https://platerecognizer.com/
MIT License
523 stars 122 forks source link

Forward AXIS alpr camera events to ParkPow visits #207

Closed danleyb2 closed 4 months ago

danleyb2 commented 4 months ago

Not testing, lacking a camera

github-actions[bot] commented 4 months ago

Risk Level 2 - /home/runner/work/deep-license-plate-recognition/deep-license-plate-recognition/parkpow/axis-lpr/app.py

The code should handle potential environment variable issues more gracefully. If TOKEN or PP_URL are not set, the application will continue to run and will fail only when trying to use these variables. It's better to check for their existence at startup and fail early if they are not set. Additionally, the exception handling in process_files is too broad, which can mask different types of exceptions. It's recommended to catch specific exceptions or at least log the exception type.

Example:

if not token or not pp_url:
    raise ValueError('TOKEN and PP_URL environment variables are required')

# In process_files
except SpecificException as e:
    lgr.error('Specific error occurred', exc_info=e)
    return f'Error uploading files: {e}', 400

Risk Level 3 - /home/runner/work/deep-license-plate-recognition/deep-license-plate-recognition/parkpow/axis-lpr/parkpow.py

The log_vehicle method has a retry loop that could potentially raise a generic Exception after 5 failed attempts due to rate limiting, which is not informative for the caller. It would be better to define a custom exception class for clarity. Additionally, the retry loop does not handle other HTTP error codes besides 429, which could lead to unexpected behavior.

Example:

class ParkPowApiError(Exception):
    pass

# In log_vehicle
if response.status_code == 429:
    # existing retry logic
else:
    raise ParkPowApiError(f'HTTP error {response.status_code}: {response.text}')

🔒🐛🚦


Powered by Code Review GPT