Repository navigation
fix(backend): validate inputs and add boundary guards in database feedback - #19890
brandonstensby-dotcom wants to merge 2 commits into
Conversation
|
@Git-on-my-level Small resilience hardening for database feedback (#19891): normalizes coordinates, enforces hash parity on idempotent retries, and adds safe fetch/parse guards with 60 hermetic tests. Could you take a look when you have a moment? |
|
Thanks @brandonstensby-dotcom — this is a solid, well-scoped hardening pass, and the hermetic test coverage is appreciated. Reviewed each changed file:
Two minor observations, neither blocking:
Since this touches validation and error-mapping on a user-data persistence path, leaving the final merge call for a human maintainer — the change itself looks correct and defensive-only. — automated maintainer feedback, AI-generated on David's behalf by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for the thorough review @Git-on-my-level! Addressed the observation in commit 04e47f7: in save_report, report.date is now stripped up front and assigned to payload['date'], ensuring the Firestore document ID and persisted payload date are 100% consistent under any whitespace variance, verified by test_save_report_strips_date_consistently_in_doc_and_payload. All 41 unit tests passing cleanly. |
|
Thanks @brandonstensby-dotcom — this is a genuinely useful hardening pass on the feedback persistence path. Reviewed all three changed files: backend/database/feedback.py
backend/routers/mobile_feedback.py
backend/tests/unit/test_database_feedback_resilience.py
One non-blocking observation: No CI results are visible on this head yet. Since this touches the feedback data-write path, leaving for human maintainer review before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
aryanorastar
left a comment
There was a problem hiding this comment.
On 04e47f7c2cf41dfcea8cb0b9922183a77b9b1c77, backend/routers/mobile_feedback.py still returns detail=str(exc) from the new ValueError handler.
|
Hey @brandonstensby-dotcom 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Summary
Hardens
backend/database/feedback.pyandbackend/routers/mobile_feedback.pywith rigorous input validation, whitespace normalization, and boundary guards:uidandtarget_idbefore database write operations.record_feedback_event: logs a warning and returnsNoneby default (best-effort, preserving caller flow), and raises descriptiveValueErrorwhenraise_on_error=True._idempotent_event_idandrecord_feedback_event_idempotentnormalize and stripuidandfeedback_idprior to computing the SHA-256 digest, ensuring identical idempotent keys regardless of client whitespace variance.get_feedback_event: safely validatesevent_idstring and returnsNoneimmediately if blank/invalid without firing an invalid document path query.get_report: validatesdatestring and returnsNoneimmediately if blank/invalid.save_report: validates thatreportis a validFeedbackReportinstance with a non-empty date string.list_negative_events: rejects non-datetime arguments or inverted datetime ranges (start_at > end_at), and returns an empty list forlimit <= 0.list_report_dates: returns empty list forlimit <= 0and safely handles client transport exceptions.backend/routers/mobile_feedback.py, catches database-levelValueErrorand converts toHTTPException(status_code=400, detail=str(exc)).Invariants & Failure-Class
How it was verified
Hermetic unit tests executed via pytest:
Results:
tests/unit/test_database_feedback_resilience.py: 40/40 passed (0.08s)tests/unit/test_feedback_report.py: 20/20 passed (0.16s)