whitelist command_health_connect_write payload keys#295
Conversation
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).
There was a problem hiding this comment.
💡 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".
| 'samples', | ||
| 'stages', |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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_writepayload keys (e.g.,data_type,value,samples,stages, etc.) so they are forwarded intopayload.data. - Add
command_health_connect_writeto 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 whitelistedsamples/stageswill 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.
|
re the codex / copilot comment about |
companion to the new
command_health_connect_writepush 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.jsadds the HC write fields to
androidNotificationKeysso they actually make it intopayload.data:data_type,value,unit,time,start_time,end_time— common fieldssystolic,diastolic— blood pressure recordsamples,stages— series records (heart rate samples, sleep stages, speed/power/cadence)exercise_type,notes— exercise sessionsclient_record_id— idempotency keyadds
command_health_connect_writetoandroidMessagesToIgnoreso HC writes don't count against the daily 500-notification rate limit. matches the existing treatment of every othercommand_*message — they're commands, not user-visible notifications.related
samples,stages) to round-trip correctly. otherwise primitives work fine on their own.