Skip to content

fix(messaging): honour bundle IDs stored under the legacy credentials.bundle key - #14592

Merged
ArnabChatterjee20k merged 2 commits into
mainfrom
fix/apns-legacy-bundle-key
Oct 16, 2026
Merged

ArnabChatterjee20k merged 2 commits into
mainfrom
fix/apns-legacy-bundle-key

Conversation

@ArnabChatterjee20k

@ArnabChatterjee20k ArnabChatterjee20k commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Since 1.5.0, PATCH /v1/messaging/providers/apns/:providerId wrote a changed bundle ID to credentials.bundle, while everything reads credentials.bundleId. #14589 fixed the write. Rows saved before that fix still hold:

  • credentials.bundleId: the bundle ID from creation (stale);
  • credentials.bundle: the bundle ID the developer set later (current).

Until such a provider is updated with a bundle ID again:

Only the update endpoint ever wrote bundle, so when it's present it's always the newest value.

Fix (read-time promotion, no data migration)

Wherever APNs credentials are read, bundle wins over bundleId:

Reader Change
Workers/Messaging.php getPushAdapter() APNs adapter uses bundle ?? bundleId
account.php create and update push target routing match on bundle ?? bundleId
Response/Model/Provider.php filter() show bundle as bundleId and hide bundle
Providers/Apns/Update.php any save promotes bundle into bundleId and unsets it, so the enable check passes and the row repairs itself

There's no migration. Rows stay as they are until their next save, and every read already behaves as if they were repaired. The trade-off is that the bundle ?? bundleId reads stay in the code. A follow-up data migration (a src/Appwrite/Migration/Version step plus a Cloud patch) could repair the rows and remove these reads.

Test Plan

  • Unit: tests/unit/Utopia/Response/Model/ProviderTest.php:

    • a legacy bundle is shown as bundleId and hidden;
    • credentials without it are unchanged;
    • empty credentials still serialize as an object.
  • E2E: testPushTargetRoutesApnsByLegacyBundleKey in AccountCustomClientTest. The API can no longer write a legacy row, so the test seeds credentials.bundle directly through the project database, using the same databaseFactory access as Traits/InternalTableName.php. It asserts:

    • create and update push target route by the legacy value;
    • GET /messaging/providers/:id shows it as bundleId;
    • a name-only provider save moves it into bundleId and removes bundle;
    • the bundle ID from creation no longer routes.

    The worker's APNs adapter read is the same expression, and isn't exercised end to end because that would mean sending through Apple.

Locally: php -l and Pint on the changed files. Unit and e2e run in CI.

Related PRs and Issues

🤖 Generated with Claude Code

….bundle key

Until #14589, updating an APNs provider's bundle ID wrote it to
credentials.bundle and left credentials.bundleId on the value from
creation. Those rows still deliver and route with the old bundle ID, and
the API shows it, until the provider is updated with a bundle ID again.

Prefer a legacy `bundle` value wherever APNs credentials are read: the
APNs adapter, push target routing and the Provider response model. Any
update of the provider now promotes it into bundleId, so the row repairs
itself on the next save.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The change retires the legacy bundle credential key in favor of bundleId for APNs providers, with read-path fallbacks during the migration window.

Files Change
app/controllers/api/account.php Duplicate-provider detection and lookups fall back to bundleId when the legacy bundle key is absent
src/Appwrite/Platform/Modules/Messaging/Http/Providers/Apns/Update.php Provider updates promote the legacy bundle value into bundleId and drop the legacy key
src/Appwrite/Platform/Workers/Messaging.php Push adapter resolution uses the same bundle → bundleId fallback for delivery
src/Appwrite/Utopia/Response/Model/Provider.php The Provider response model filters the legacy bundle key out of serialized credentials
tests/unit/Utopia/Response/Model/ProviderTest.php Unit coverage for the legacy-key filtering in the Provider model

Reviewed commit: daa9198

@ghost

ghost commented Oct 16, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The newly added test follows established database-seeding and coroutine patterns, and its syntax check passes; I found no issue in the incremental changes.

This change makes legacy APNs credentials.bundle values authoritative for delivery, push-target routing, and provider responses, while promoting and removing the legacy key on the next provider update. It adds unit and end-to-end coverage, including a database-seeded legacy provider scenario that exercises routing, response serialization, and repair on save.

Latest changes: The newest commits add an end-to-end test that seeds a legacy APNs credential directly in the project database and verifies routing, API serialization, and promotion on a name-only provider update.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
app/controllers/api/account.php Uses the legacy bundle key as a fallback when matching APNs providers for push-target routing.
src/Appwrite/Platform/Modules/Messaging/Http/Providers/Apns/Update.php Promotes a legacy bundle credential to bundleId and removes the legacy key during provider updates.
src/Appwrite/Platform/Workers/Messaging.php Uses the legacy bundle credential as a fallback when configuring the APNs adapter.
src/Appwrite/Utopia/Response/Model/Provider.php Serializes a legacy bundle value as bundleId and omits the legacy key from credentials.
tests/e2e/Services/Account/AccountCustomClientTest.php Adds a database-seeded legacy APNs provider scenario covering create/update routing, API response shape, and credential repair.
tests/unit/Utopia/Response/Model/ProviderTest.php Tests legacy credential promotion in responses, unchanged credentials, and empty credentials serialization.

Reviewed the commits since daa9198 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost 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.

🔵 Tier A · Looks good to merge. Summary

Comment thread app/controllers/api/account.php Resolved
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/apns-legacy-bundle-key (after).

Metric Before After Change
🚀 Requests/sec 216.21 222.94 ⚪ +3.1%
⏱️ Latency P50 79.36 ms 78.42 ms ⚪ -1.2%
⏱️ Latency P95 186.41 ms 176.29 ms 🟢 -5.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 78.42 176.29 13,680 222.94 -10.12
Account 152.37 275.95 720 12.53 -8.34
TablesDB 77.37 146.84 7,440 124.58 +6.84
Storage 68.53 156.84 3,600 61.56 -23.27
Functions 108.55 204.8 1,920 33.46 -32.51

Top API waits (after)

API request Max wait (ms)
account.name.update 409.77
tablesdb.rows.create 371.99
account.prefs.update 370.29
functions.create 363.43
tablesdb.rows.update 339.58

…o end

Seed an APNs provider's stored credentials with the legacy `bundle` key
through the project database, since the API can no longer write it, and
assert that create and update push target route by it, the provider API
shows it as bundleId, and the next provider save repairs the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ArnabChatterjee20k
ArnabChatterjee20k merged commit 540e21d into main Oct 16, 2026
66 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Oct 21, 2026
6 tasks
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.

1 participant