Refactor: extract _image_cache_key helper and drop stale response_model on get_nearby_issues#587
Draft
Copilot wants to merge 2 commits intobolt-optimization-cache-serialization-14526281583048350032from
Draft
Conversation
…odel on get_nearby_issues Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com> Agent-Logs-Url: https://github.com/RohanExploit/VishwaGuru/sessions/10a14469-101a-4f94-9d2e-d0cc6c3a611a
Copilot
AI
changed the title
[WIP] Fix indentation error and optimize cache stability
Refactor: extract _image_cache_key helper and drop stale response_model on get_nearby_issues
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Addresses two review comments from PR #573: eliminates duplicated MD5 cache-key construction in
detection.pyand removes a misleadingresponse_modelannotation that diverged from the actual raw-Responsereturn type.Changes
backend/routers/detection.py: Extracted_image_cache_key(prefix, image_bytes) -> strhelper. All 8_cached_*functions now delegate to it instead of inlininghashlib.md5(image_bytes).hexdigest()with a manual f-string each time.backend/routers/issues.py: Removedresponse_model=List[NearbyIssueResponse]fromget_nearby_issues. The handler returns a pre-serialisedfastapi.Response; keeping the annotation caused the generated OpenAPI schema to misrepresent the actual contract and bypassed no-op Pydantic validation.Type of Change
Related Issue
Closes #
Testing Done
Screenshots (if applicable)
Checklist
Co-Authors
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.
Summary by cubic
Consolidates image cache key generation into a single helper for deterministic keys and fewer cache misses. Also fixes a wrong
response_modelon the nearby issues route and a small indentation error.Cache Stability
_image_cache_key(prefix, image_bytes)and used it across all 8_cached_*functions for consistent MD5-based keys.Bug Fixes
response_modelfromGET /issues/nearbysince it returns a rawResponse.Written for commit fea1bed. Summary will update on new commits.