Skip to content

mdm: A DEP device refresh keeps the MDM migration deadline - #1731

Merged
np5 merged 1 commit into
mainfrom
20260924-mdm-dep-keep-migration-deadline
Nov 11, 2026
Merged

np5 merged 1 commit into
mainfrom
20260924-mdm-dep-keep-migration-deadline

Conversation

@sebastian-zentral

@sebastian-zentral sebastian-zentral commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

How Apple reports the MDM migration deadline

Found while testing against the Apple API:

  • POST /devices (Get Device Details) never includes mdm_migration_deadline, even when a deadline is set in ABM. The documentation doesn't say this: all three endpoints are documented as returning the same Device object, where the field is optional.
  • POST /server/devices (fetch) and POST /devices/sync (sync) report the deadline. They keep reporting it after it is removed in ABM, and only stop when the device changes MDM server.

Problem

dep_device_update_dict() treated an absent key as no deadline. So every path that reads a device back through get_devices() cleared the deadline the sync had just stored:

  • the default enrollment assignment (apply_dep_device_updates)
  • assign_dep_device_profile
  • refresh_dep_device (the refresh button)

This happened on a tenant after a device was moved to Zentral with a migration deadline set in ABM. The sync stored the deadline at 10:45:01, and the default enrollment assignment cleared it at 10:45:02. A later sync stored the deadline again, after it had been changed in ABM, and the next refreshes cleared it again.

Change

dep_device_update_dict() updates the deadline from the keys of the payload, the same way it already handles released_by_replacement. There's no flag, and the callers don't change:

  • mdm_migration_deadline in the payload: stored.
  • op_type is deleted: cleared, because the device left the MDM server.
  • key absent otherwise: the stored deadline is left alone. This covers the device details, and syncs that report other changes.

A deadline removed in ABM stays in Zentral until the device changes MDM server, because Apple keeps reporting it. Zentral can't detect the removal. The changelog says so.

Tests

  • The default enrollment assignment, the profile assignment and the refresh keep the deadline.
  • A sync that reports the device modified, without the key, keeps the deadline.
  • The four tests above fail without the change.
  • A refresh stores a new deadline when the endpoint reports one.
  • A sync that reports the device as deleted, because it moved to another MDM server, clears the deadline.

tests.mdm.test_dep, tests.mdm.test_management_dep_device, tests.mdm.test_api_dep_views and tests.mdm.models.test_dep_device_model pass (110 tests), and ruff is clean.

🤖 Generated with Claude Code

@coveralls

coveralls commented Sep 24, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 43012115984

Coverage increased (+0.001%) to 91.599%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: 4 of 4 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 60906
Covered Lines: 55789
Line Coverage: 91.6%
Coverage Strength: 0.92 hits per line

💛 - Coveralls

@sebastian-zentral
sebastian-zentral force-pushed the 20260924-mdm-dep-keep-migration-deadline branch 4 times, most recently from e972253 to a9af3d6 Compare October 1, 2026 09:46
Apple leaves the MDM migration deadline out of the device details, even
when the device has one. Zentral read an absent key as no deadline, so
the refresh of a device, and the profile assignments that read the
device back from the device details endpoint, cleared the deadline that
the synchronization had just stored.

The device lists, the fetch and the sync, report the deadline, and keep
reporting it after it is removed in Apple Business Manager. Only a
change of MDM server clears it.

The deadline is updated from the keys of the payload now: a deadline in
the payload is stored, a deleted operation clears it, because the
device left the MDM server, and an absent key leaves it alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sebastian-zentral
sebastian-zentral force-pushed the 20260924-mdm-dep-keep-migration-deadline branch from a9af3d6 to 46f5ece Compare November 11, 2026 11:27
@np5
np5 merged commit 46f5ece into main Nov 11, 2026
11 checks passed
@np5
np5 deleted the 20260924-mdm-dep-keep-migration-deadline branch November 11, 2026 11:40
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.

3 participants