Skip to content

whitelist command_health_connect_write payload keys#295

Open
anasmadrhar wants to merge 1 commit into
home-assistant:mainfrom
anasmadrhar:feat/health-connect-write-keys
Open

whitelist command_health_connect_write payload keys#295
anasmadrhar wants to merge 1 commit into
home-assistant:mainfrom
anasmadrhar:feat/health-connect-write-keys

Conversation

@anasmadrhar
Copy link
Copy Markdown

companion to the new command_health_connect_write push command being added in home-assistant/android#6799. without this whitelist update HC payloads sent through this proxy lose all their fields by the time they reach the device.

changes

functions/android.js

  1. adds the HC write fields to androidNotificationKeys so they actually make it into payload.data:

    • data_type, value, unit, time, start_time, end_time — common fields
    • systolic, diastolic — blood pressure record
    • samples, stages — series records (heart rate samples, sleep stages, speed/power/cadence)
    • exercise_type, notes — exercise sessions
    • client_record_id — idempotency key
  2. adds command_health_connect_write to androidMessagesToIgnore so HC writes don't count against the daily 500-notification rate limit. matches the existing treatment of every other command_* message — they're commands, not user-visible notifications.

related

Adds the data fields used by the new Android command_health_connect_write
push command to the androidNotificationKeys whitelist so they pass through
to the device, and adds command_health_connect_write to the
androidMessagesToIgnore list so command pushes don't count against the
user's daily notification rate limit (matching the existing treatment of
command_* messages).
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bba24109e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread functions/android.js
Comment on lines +123 to +124
'samples',
'stages',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize Health Connect arrays as JSON

Adding samples/stages to the whitelist makes the relay copy these fields into payload.data, but this function still applies String(...) to all whitelisted values (payload.data[key] = String(req.body.data[key])). When callers send the expected array/object payloads for series records (e.g., heart-rate samples or sleep stages), those values are coerced to non-JSON strings like [object Object] or comma-joined text, so the Android command handler cannot reconstruct the original data.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Android push payload allowlist to support the upcoming command_health_connect_write command so its data fields are preserved through the proxy, and excludes that command from rate-limit counting like other command_* messages.

Changes:

  • Whitelist command_health_connect_write payload keys (e.g., data_type, value, samples, stages, etc.) so they are forwarded into payload.data.
  • Add command_health_connect_write to the “messages to ignore” list so it doesn’t count against the daily notification rate limit.
Comments suppressed due to low confidence (1)

functions/android.js:133

  • payload.data[key] = String(req.body.data[key]) will not round-trip array/object values (e.g., the newly whitelisted samples/stages will become comma-joined strings or "[object Object]"). If these fields are intended to carry structured data, serialize non-null objects/arrays with JSON (e.g., JSON.stringify) before sending to FCM so the Android client can decode them reliably.
      androidNotificationKeys.forEach((key) => {
        if (Object.hasOwn(req.body.data, key)) {
          payload.data[key] = String(req.body.data[key]);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@anasmadrhar
Copy link
Copy Markdown
Author

re the codex / copilot comment about samples/stages ending up as [object Object] or comma-joined strings: that's exactly the bug fixed in #294, which switches the whitelist loop to JSON.stringify for non-null objects. this PR is intentionally scoped to just the whitelist additions so each change is independently reviewable. the PR body notes the dependency — primitives work standalone here, the array fields need #294 too. if you'd prefer I rebase #295 on top of #294's branch (or squash both into one PR) happy to do either, just let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants