Fixing unreleased issue with vpp installs on byod#46108
Draft
georgekarrv wants to merge 1 commit into
Draft
Conversation
| "original_err", err.Error()) | ||
| } | ||
|
|
||
| clientUserID = recoveredClientUserID |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #46108 +/- ##
========================================
Coverage 66.82% 66.83%
========================================
Files 2754 2754
Lines 220138 220244 +106
Branches 10905 10905
========================================
+ Hits 147117 147209 +92
- Misses 59730 59736 +6
- Partials 13291 13299 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes for the BYOD/User-Enrollment VPP install flow shipped under #31138, all caught during QA on
gkarr-fix-byod-vpp:1. Switch VPP user registration from v2 (async) to v1 (sync)
The original implementation called Apple's
/mdm/v2/users/create, which is asynchronous: a 200 response only confirms the registration was queued, with nouserIdreturned. Fleet was storing the row asregisteredbased on theeventIdalone, which masked failures and leftapple_user_idpermanentlyNULL. Switched to Apple's legacy v1registerVPPUserSrvendpoint, which returns the full user record (including Apple'suserId) in the same response, so we know definitively whether registration succeeded.vpp.RegisterUser(token, clientUserID, managedAppleID)posts tohttps://vpp.itunes.apple.com/mdm/registerVPPUserSrvwith the token in the request body (v1 doesn't use theAuthorizationheader).ensureVPPClientUserno longer writes "pending" rows on failure — v1's sync contract means we either succeed or surface the error.CreateUserstypes and tests.2. Show a clear error when an end user already has the app installed personally
On BYOD/User-Enrolled hosts, when an end user has already installed an app from the App Store outside of Fleet, Apple's
InstallApplicationcommand fails with"The app with iTunes Store ID <id> is already installed."(code 12042). Previously Fleet treated this as success and entered theInstalledApplicationListverification loop — which never resolves on User Enrollment, since Apple'smanagedAppsOnly: truefilter doesn't return personally-installed apps. The install appeared stuck."Failed. This app is already installed. Please delete app first, an install via self-service."3. Self-heal a stale
vpp_client_userscache against AppleIf Fleet's cached
client_user_idever drifts from Apple's record (DB restore from a stale backup, manual tampering, future bug), Apple rejectsAssociateAssetswith code 9609"Unable to find the registered user."and the install fails terminally. Apple enforces one VPP user per(location, managed_apple_id), so blindly re-registering hits a different error (9635). The recovery is two-step:GET /mdm/v2/users?managedAppleId=…. If Apple has an active record, upsert thatclientUserIdback intovpp_client_usersand retry the associate.Each branch logs a distinct
WARNso the self-heal is visible in operator dashboards. Only one retry — if the follow-up associate fails, the second error is surfaced.Test plan
make lint-go-incremental— cleango test ./server/mdm/apple/vpp/... ./ee/server/service/... ./server/service/ -run '<targeted>'— all greenapple_user_idNULL.vpp_client_users.client_user_idand observing the WARN line + restored UUID.