Repository navigation
fix(database): validate inputs and normalize timestamps in desktop previews - #20087
brandonstensby-dotcom wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 4/5
- In
backend/database/desktop_previews.py,_publish_preview_transactionnever passesupdated_at, so the pointer always uses the current time and the new validation path is only exercised by the unit test; pass the intended timestamp or align the behavior and test. - In
backend/tests/unit/test_database_desktop_previews_resilience.py, the fixture’sp0375d1f909slug makes manifest normalization reject its identity fields, so the generation tests cannot use this fixture; update both identity values to match a valid manifest.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/database/desktop_previews.py">
<violation number="1" location="backend/database/desktop_previews.py:194">
P3: Only the new unit test exercises this block: the sole production caller `_publish_preview_transaction` never passes `updated_at`, so the pointer always falls back to `datetime.now(timezone.utc)` and this added validation/coercion is inert. Also note `replace(tzinfo=timezone.utc)` reinterprets a naive wall-clock value as already-UTC rather than converting it, so a caller passing local time would silently store the wrong instant. Either thread `updated_at` through `publish_preview` or document the UTC interpretation.</violation>
</file>
<file name="backend/tests/unit/test_database_desktop_previews_resilience.py">
<violation number="1" location="backend/tests/unit/test_database_desktop_previews_resilience.py:24">
P3: This fixture is not valid for `feature-test`: its slug derives `p0375d1f909`, so manifest normalization rejects these identity fields. Update both values so the generation tests use a valid manifest.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| raise ValueError(f"generation mismatch: expected {expected_generation}, current {current_generation}") | ||
| if current.get("source_sha") == manifest["source_sha"]: | ||
| return current | ||
| if updated_at is not None: |
There was a problem hiding this comment.
P3: Only the new unit test exercises this block: the sole production caller _publish_preview_transaction never passes updated_at, so the pointer always falls back to datetime.now(timezone.utc) and this added validation/coercion is inert. Also note replace(tzinfo=timezone.utc) reinterprets a naive wall-clock value as already-UTC rather than converting it, so a caller passing local time would silently store the wrong instant. Either thread updated_at through publish_preview or document the UTC interpretation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/desktop_previews.py, line 194:
<comment>Only the new unit test exercises this block: the sole production caller `_publish_preview_transaction` never passes `updated_at`, so the pointer always falls back to `datetime.now(timezone.utc)` and this added validation/coercion is inert. Also note `replace(tzinfo=timezone.utc)` reinterprets a naive wall-clock value as already-UTC rather than converting it, so a caller passing local time would silently store the wrong instant. Either thread `updated_at` through `publish_preview` or document the UTC interpretation.</comment>
<file context>
@@ -164,11 +179,23 @@ def _build_preview_pointer(
+ raise ValueError(f"generation mismatch: expected {expected_generation}, current {current_generation}")
if current.get("source_sha") == manifest["source_sha"]:
return current
+ if updated_at is not None:
+ if not isinstance(updated_at, datetime):
+ raise ValueError("updated_at must be a datetime")
</file context>
| "slug": "feature-test", | ||
| "source_sha": "0123456789abcdef0123456789abcdef01234567", | ||
| "app_name": "Omi Preview (feature-test)", | ||
| "bundle_id": "com.omi.preview.p48ec788481", |
There was a problem hiding this comment.
P3: This fixture is not valid for feature-test: its slug derives p0375d1f909, so manifest normalization rejects these identity fields. Update both values so the generation tests use a valid manifest.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_database_desktop_previews_resilience.py, line 24:
<comment>This fixture is not valid for `feature-test`: its slug derives `p0375d1f909`, so manifest normalization rejects these identity fields. Update both values so the generation tests use a valid manifest.</comment>
<file context>
@@ -0,0 +1,104 @@
+ "slug": "feature-test",
+ "source_sha": "0123456789abcdef0123456789abcdef01234567",
+ "app_name": "Omi Preview (feature-test)",
+ "bundle_id": "com.omi.preview.p48ec788481",
+ "url_scheme": "omi-preview-p48ec788481",
+ "built_at": "2026-09-30T12:00:00Z",
</file context>
…review fixture identities
|
Resolved cubic-dev-ai review issues:
|
|
Thanks @brandonstensby-dotcom — this is a tidy, genuinely useful hardening pass on the desktop preview manifest path. Reviewed both files: backend/database/desktop_previews.py
backend/tests/unit/test_database_desktop_previews_resilience.py
No CI check runs are visible on this PR yet, so please make sure they trigger (or rebase if the fork gate needs it). Since this touches validation of preview distribution manifest data (dmg_url, dmg_sha256, source_sha), I'm leaving the merge call to a human maintainer. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for this fix, @brandonstensby-dotcom! Your commits are being carried forward in #22207 (cherry-picked with your original authorship intact) so they can land with the current CI and repo conventions. Closing this in favor of that branch — your contribution is credited there and in the git history. |
|
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! |
…tamps in desktop previews (#22207) * fix(backend): validate inputs and normalize timestamps in database desktop previews * fix(database): cleanly normalize aware timestamps to UTC and update preview fixture identities --------- Co-authored-by: brandonstensby-dotcom <[email protected]>
Closes #20086
Summary
Hardens target database module with defensive boundary checks and fail-fast validation:
Review & Settlement
cc @Git-on-my-level for review!
Base USDC Coordinates: 0xbB9686b9684421A8e326AC0F8B3eCf88Df975120