Skip to content

Snapshot middleware updates2#256

Merged
danleyb2 merged 11 commits into
masterfrom
snapshot-middleware-updates2
Sep 9, 2025
Merged

Snapshot middleware updates2#256
danleyb2 merged 11 commits into
masterfrom
snapshot-middleware-updates2

Conversation

@danleyb2
Copy link
Copy Markdown
Collaborator

@danleyb2 danleyb2 commented Aug 27, 2025

  • Fix overwrite_plate param. Add support for Snapshot detection_mode=vehicle responses format.
  • Fix duplicates in ParkPow. Disable forwarding ParkPow errors to cameras(status 400) causing retries.
  • Add env.PARKPOW_FORWARDING to enable PP forwarding by default
  • Improve runtime logging, Refactor code to functions.
  • feat: Add env.SNAPSHOT_CONFIG for setting default config
  • feat: upgrade "wrangler": "^4.31.0"
  • feat: Add a way to Log RAW camera JSONs to S3

@danleyb2 danleyb2 changed the title Refs/heads/snapshot middleware updates2 Snapshot middleware updates2 Aug 27, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @danleyb2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on updating dependencies, enhancing camera data processing, and refining the integration with the Snapshot API. Key improvements include better handling of different Snapshot API response formats, more robust data validation for camera inputs, and flexible configuration merging. Additionally, logging has been streamlined, and error handling has been improved to provide clearer responses and prevent unnecessary retries for invalid data.

Highlights

  • Dependency Updates: The wrangler dependency and its related Cloudflare Worker packages have been updated to their latest versions, ensuring the middleware benefits from the newest features and bug fixes.
  • Improved Logging for Camera Data: A new debugLog getter has been introduced for camera classes, allowing for logging of camera data without including large image payloads, which significantly improves log readability and reduces log volume.
  • Enhanced Camera Data Processing: The Survision camera's data validation has been enhanced, and its orientation mapping logic refined for better accuracy. The Genetec camera's processing now uses the 'Vehicle Orientation' attribute for more precise direction determination.
  • Refined Error Handling: A new InvalidResults exception has been implemented to specifically handle cases where the Snapshot API returns empty or invalid results, preventing unnecessary retries by the client.
  • Flexible Configuration Management: A mergeConfigs utility and updated requestParams now allow for combining configuration parameters from both query strings and environment variables, providing greater flexibility in deployment and operation.
  • Advanced Snapshot API Integration: The Snapshot API response handling has been improved to detect and correctly process both V1 and V2 formats, with corresponding adjustments to the plate overwriting logic.
  • Streamlined Error Responses: Error responses across the middleware have been refined to provide more informative messages and appropriate HTTP status codes, including returning 200 for certain invalid requests to avoid client-side retries.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant updates to the snapshot middleware. Key changes include upgrading dependencies like wrangler, adding support for a new V2 data format from the Snapshot API, and enhancing configuration options by allowing settings to be passed via environment variables. The code has been refactored for better clarity and robustness, with improved error handling, more specific request validation, and cleaner logging by removing image data from logs. Overall, these are excellent improvements that enhance the middleware's functionality and maintainability. I've included a few suggestions to address potential bugs and improve consistency.

Comment thread snapshot-middleware/src/index.js Outdated
Comment thread snapshot-middleware/src/snapshot.js
Comment thread snapshot-middleware/src/cameras.js Outdated
Comment thread snapshot-middleware/src/exceptions.js Outdated
- Fix overwrite_plate param. Add support for Snapshot `detection_mode=vehicle` responses format.
- Fix duplicates in ParkPow. Disable forwarding ParkPow errors to cameras(status 400) causing retries.
- Add `env.PARKPOW_FORWARDING` to enable PP forwarding by default
- Improve runtime logging, Refactor code to functions.
@danleyb2 danleyb2 force-pushed the snapshot-middleware-updates2 branch from 16d89d4 to 458ab88 Compare September 8, 2025 04:18
@danleyb2 danleyb2 merged commit eecb6ce into master Sep 9, 2025
1 check passed
@danleyb2 danleyb2 deleted the snapshot-middleware-updates2 branch September 9, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants