Repository navigation
Conversation
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more
Re-trigger cubic
|
Hi @ZachL111 — thank you for finding and writing up this request/protocol boundary issue. We consolidated this group into a smaller aggregate PR with shared validation helpers and focused tests: #8367. Your original discovery, reproduction details, and candidate fix are credited in the new PR body and commit metadata. I’m closing this individual PR as superseded by #8367, not because the issue is invalid. Thanks again for surfacing it. |
|
Hey @ZachL111 👋 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:
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 This aggregates the high-signal request/protocol-boundary fixes from @ZachL111 into shared validation helpers instead of endpoint-by-endpoint patches. Changes: - add `utils.request_validation` for multipart JSON form parsing, bounded query params, real calendar dates, UTC-safe sync filename timestamps, and image chunk envelopes - route app/persona multipart JSON parsing through the shared helper - enforce bounded list/history query parameters and real calendar dates at request boundaries - validate sync upload filename timestamps with one UTC-aware parser for v1/v2 paths - reject invalid websocket image chunk envelopes/sequences instead of silently ignoring malformed chunks - validate parallel event/action-item status arrays on the Pydantic request models - replace a previous `sys.meta_path`/MagicMock-heavy app JSON test with direct helper contract coverage Supersedes/redesigns parts of #8218, #8219, #8220, #8222, #8227, #8231, #8260, #8263, #8275, #8278, #8279, #8280, #8295, #8303, #8309, #8321. Original issue discovery, reproductions, and candidate fixes by @ZachL111 — thank you for surfacing these boundary bugs. This PR keeps the useful findings while moving the implementation toward shared contracts and smaller tests. ## Deferred from the Oracle boundary bucket Not included here because they need separate design or would broaden this PR: - #8224 shared-chat malformed record behavior - #8240 notification payload model cleanup - #8244 task due-date validation - #8257 app generate-description request validation - #8266/#8270 MCP SSE JSON-RPC validation - #8271 segment assignment bounds beyond the shared-array model work - #8289 social/persona not-found policy ## Test plan - [x] `pytest tests/unit/test_request_validation_contracts.py tests/unit/test_sync_file_paths_filename_none.py tests/unit/test_apps_create_app_json.py tests/unit/test_conversation_events_bounds.py -q` → 34 passed - [x] `python -m py_compile ...` over modified modules/tests - [x] `git diff --check` - [x] `bash backend/testing/e2e/run.sh -q --tb=short` → 73 passed, 6 skipped <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/8367?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
- add shared request validation helpers for multipart JSON, query bounds, calendar dates, sync filenames, and image chunks - validate app/persona form JSON through a common helper - enforce bounded list/history query parameters and real calendar dates - validate sync upload timestamps with UTC-aware parsing - reject invalid websocket image chunk envelopes instead of silently ignoring them - validate parallel event/action-item status arrays at the request-model boundary Supersedes parts of BasedHardware#8218, BasedHardware#8219, BasedHardware#8220, BasedHardware#8222, BasedHardware#8227, BasedHardware#8231, BasedHardware#8260, BasedHardware#8263, BasedHardware#8275, BasedHardware#8278, BasedHardware#8279, BasedHardware#8280, BasedHardware#8295, BasedHardware#8303, BasedHardware#8309, BasedHardware#8321. Original issue discovery, reproductions, and candidate fixes by @ZachL111. Co-authored-by: ZachL111 <[email protected]>
Summary
PATCH /v1/conversations/{conversation_id}/action-items(set_action_item_status) takes two parallel lists,items_idxandvalues, and toggles the completed state of the action items at those indices. It only guards the upper bound on the index, so a negativeaction_item_idxlike-1passes the check and writes toaction_items[-1], flipping the wrong action item with no error. A separate problem: if the client sendsitems_idxandvaluesof different lengths,data.values[i]runs off the end and raisesIndexError, which FastAPI turns into a 500. This PR rejects a length mismatch with 422 and bounds-checks both ends of the index so an out-of-range value is skipped instead of corrupting data or 500ing.Root cause
In
backend/routers/conversations.py,set_action_item_statusloops overdata.items_idxtwice (once onconversation.structured.action_items, once when mirroring to the standalone collection). Both loops use the same one-sided guard:action_item_idx >= len(action_items)only rejects indices that are too high. A negative index passes the check, andaction_items[action_item_idx]then resolves it from the end of the list, so-1silently mutates the last action item rather than being skipped. The value read isdata.values[i], indexed by the position initems_idx, not byaction_item_idx. There is no check thatitems_idxandvaluesare the same length, so a request with more entries initems_idxthan invaluesreachesdata.values[i]withipast the end ofvaluesand raisesIndexError, which surfaces as a 500. The sibling events endpoint in this same file pairs its indices and values up front; this handler did not.Fix
Validate the two lists are the same length before doing any work, and bounds-check both ends of the index in each loop:
The
0 <= action_item_idx < len(action_items)check is applied in both loops, so a negative or too-large index is skipped in both the structured update and the mirrored update. A request with matching lengths and in-range indices behaves exactly as before.Testing
Added
backend/tests/unit/test_conversation_action_item_bounds.py(registered inbackend/test.sh). The conversations router has a heavy import graph, so the test mounts it under a stub finder (heavy deps replaced with auto-mock modules, the real lightweightutilssubmodules re-pinned) and callsset_action_item_statusdirectly, the same pattern the other router unit tests use. The cases: mismatcheditems_idx/valueslengths returns 422 instead of raisingIndexError; a negative index (-1) leaves every action item unmodified instead of writing to the last one; and a valid in-range index still flips that item's completed flag while leaving the others alone. Verified red to green: the test fails on current main and passes with this change.PR status check
No open PR changes this logic. PR #6946 (the unified auth and BYOK middleware refactor) rewires the auth dependencies across many routers including this one, but it does not change this handler's body logic, so it does not address this bug. The bounds check and the length validation added here do not appear anywhere in this file's history, so this is not a previously reverted fix being resubmitted. No filed GitHub issue matches.