Skip to content

[codex] Exclude clinical types from HealthKit background delivery - #1414

Merged
Asherlc merged 1 commit into
mainfrom
Asherlc/sentry-7587720785
Jul 1, 2026
Merged

Asherlc merged 1 commit into
mainfrom
Asherlc/sentry-7587720785

Conversation

@Asherlc

@Asherlc Asherlc commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Fixes DOFEK-MOBILE-12 by keeping HealthKit clinical records readable while excluding HKClinicalType values from background delivery registration.

The root cause was that backgroundDeliveryTypes reused every readable HKSampleType, which caused unsupported clinical record sample types to be passed into HKHealthStore.enableBackgroundDelivery on iOS.

This also updates the HealthKit type tests and records the production incident baseline.

Validation: swift test --package-path packages/mobile/modules/health-kit, iOS Simulator SDK xcodebuild package build, pnpm test:mobile, root/server/web typechecks, and pnpm lint.


Summary by cubic

Exclude HKClinicalType from HealthKit background delivery while keeping clinical records readable. Fixes the production setup failure reported in DOFEK-MOBILE-12.

  • Bug Fixes
    • Build backgroundDeliveryTypes from readable HKSampleType minus HKClinicalType on iOS to avoid unsupported calls to HKHealthStore.enableBackgroundDelivery.
    • Updated tests in packages/mobile/modules/health-kit to assert clinical types are excluded and counts match.
    • Logged the incident in docs/production-incident-baseline.md.

Written for commit 56c510e. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed HealthKit background delivery on iOS by excluding unsupported clinical record types from background sync registration.
    • Prevented background delivery errors that could occur when the app tried to wake for clinical HealthKit samples.
    • Updated validation to reflect the supported set of background-deliverable HealthKit types, while keeping menstrual flow data included.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @Asherlc, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ffe8c035-fb14-4b38-8b35-2dc3918fef30

📥 Commits

Reviewing files that changed from the base of the PR and between 834f3e4 and 56c510e.

📒 Files selected for processing (3)
  • docs/production-incident-baseline.md
  • packages/mobile/modules/health-kit/Tests/HealthKitTypesTests.swift
  • packages/mobile/modules/health-kit/ios/HealthKitTypes.swift

📝 Walkthrough

Walkthrough

Excludes HKClinicalType sample types from HealthKit background delivery registration on iOS to fix HKHealthStore.enableBackgroundDelivery failures. Updates Swift tests to assert backgroundDeliveryTypes excludes clinical types (e.g., labResultRecord) while retaining non-clinical types like menstrualFlow. Adds an incident documentation entry.

Changes

HealthKit Background Delivery Clinical Type Fix

Layer / File(s) Summary
Exclude clinical types from delivery set
packages/mobile/modules/health-kit/ios/HealthKitTypes.swift
Adds #if os(iOS) guard to skip HKClinicalType-conforming sample types when building backgroundDeliveryTypes.
Test expectations updated
packages/mobile/modules/health-kit/Tests/HealthKitTypesTests.swift
Replaces membership test to assert backgroundDeliveryTypes == readableSampleTypes.subtracting(clinicalSampleTypes), excludes labResultRecord on iOS while keeping menstrualFlow, and updates total-count assertion to use the non-clinical count.
Incident documentation
docs/production-incident-baseline.md
Adds a 2026-07-01 incident entry documenting the failure, root cause, mitigation, and validation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

Not applicable — this is a scoped logic fix and test update, not a multi-component flow.

Suggested labels: area/mobile, type/bug

Per AGENTS.md's preference for root-cause fixes: this change correctly excludes HKClinicalType at the source (HealthKitTypes.swift) rather than filtering errors downstream or catching the enableBackgroundDelivery failure — that's the right call. Test coverage in HealthKitTypesTests.swift was updated to match the new invariant, not just patched to pass.

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is clear and imperative, but it uses [codex] instead of the required area prefix for a mobile HealthKit change. Rename it to use an area prefix, e.g. [mobile] Exclude clinical types from HealthKit background delivery.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Storybook previews for 6931581e are ready:

This comment updates automatically on each PR push.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Mobile Preview

Scan to open on device:

QR code for dofek://preview/pr-1414

Channel pr-1414
Deep Link dofek://preview/pr-1414
Commit 6931581

To test on device:

  1. Build and install the preview client: PREVIEW_CHANNEL=pr-1414 pnpm expo prebuild --clean -p ios
  2. Or tap deep link on an existing preview build: dofek://preview/pr-1414

Each PR gets its own channel. Build a preview client with PREVIEW_CHANNEL=pr-{N} to test.

@Asherlc
Asherlc marked this pull request as ready for review July 1, 2026 19:00
Copilot AI review requested due to automatic review settings July 1, 2026 19:00
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Fix HealthKit background delivery by excluding unsupported clinical types. Tests updated to verify exclusion. No logic changes outside HealthKit module.

Re-trigger cubic

@Asherlc
Asherlc merged commit 203a823 into main Jul 1, 2026
90 checks passed
@Asherlc
Asherlc deleted the Asherlc/sentry-7587720785 branch July 1, 2026 19:10
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