Skip to content

48093 auld api gitops latest os version - #50213

Merged
andymFleet merged 25 commits into
mainfrom
48093-auld-api-gitops-latest-os-version
Aug 5, 2026
Merged

48093 auld api gitops latest os version#50213
andymFleet merged 25 commits into
mainfrom
48093-auld-api-gitops-latest-os-version

Conversation

@andymFleet

@andymFleet andymFleet commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #48093

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

Testing

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

New Fleet configuration settings

  • Setting(s) is/are explicitly excluded from GitOps

If you didn't check the box above, follow this checklist for GitOps-enabled settings:

  • Verified that the setting is exported via fleetctl generate-gitops

  • Verified that the setting is cleared on the server if it is not supplied in a YAML file (or that it is documented as being optional)

Summary by CodeRabbit

  • New Features

    • Added “latest” version enforcement for macOS, iOS, and iPadOS updates using required deadline_days.
    • Updates dynamically target each device’s available OS version and deadline.
    • Configuration and GitOps outputs now include deadline_days.
  • Bug Fixes

    • Improved validation when switching update modes or omitting deadline settings.
    • GitOps updates now clear previously stored deadline values when omitted.
    • Changes to deadline_days are detected and applied consistently.

@andymFleet
andymFleet requested a review from a team as a code owner July 30, 2026 14:11
Copilot AI lite review requested due to automatic review settings July 30, 2026 14:11
@andymFleet
andymFleet marked this pull request as draft July 30, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for configuring Apple OS updates in a new "latest" mode (with deadline_days) across API, GitOps, and declaration generation, including validation and variable-substitution safeguards.

Changes:

  • Extend AppleOSUpdateSettings with deadline_days, a "latest" minimum_version sentinel, and mode-specific validation/configured logic.
  • Generate OS update declarations using Fleet-internal $FLEET_VAR_HOST_TARGET_OS_VERSION / $FLEET_VAR_HOST_TARGET_OS_DEADLINE placeholders in "latest" mode, and ensure those vars are rejected in admin-uploaded declarations.
  • Update GitOps/appconfig/team-spec paths and tests to round-trip and clear deadline_days.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/service/integration_enterprise_test.go Updates integration expectations to include deadline_days in MDM OS update settings.
server/service/client.go GitOps apply: sends explicit nulls for deadline_days when omitted to keep YAML as source of truth.
server/service/apple_mdm_test.go Adds coverage ensuring Fleet-internal OS update variables are rejected in user declarations.
server/service/appconfig.go Treats deadline_days changes as OS update edits and adds license gating for deadline_days edits.
server/service/appconfig_test.go Adds tests for free-tier gating and change detection around deadline_days.
server/mdm/apple/apple_mdm.go Skips Apple version lookup when minimum_version is the "latest" sentinel.
server/mdm/apple/apple_mdm_test.go Adds tests confirming "latest" bypasses Apple metadata lookups while mixed modes still validate concrete versions.
server/fleet/mdm.go Introduces Fleet-internal var names for host-target OS version/deadline.
server/fleet/app.go Adds deadline_days, "latest" sentinel, and validation/configured semantics for Apple OS updates.
server/fleet/app_test.go Adds unit tests for "latest" validation and Configured() behavior.
ee/server/service/teams.go Ensures team OS update change detection/validation includes deadline_days and validates iOS/iPadOS updates in specs.
ee/server/service/teams_test.go Adds tests for team modify/spec apply behaviors involving deadline_days and latest-mode declarations.
ee/server/service/mdm.go Emits placeholders + tracks fleet vars when generating latest-mode OS update declarations.
ee/server/service/mdm_test.go Tests declaration JSON and tracked vars for both latest-mode and specific-version mode.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.yml Updates expected YAML output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.yml Updates expected YAML output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.yml Updates expected YAML output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.yml Updates expected YAML output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigSet.yml Updates expected YAML output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigEmpty.yml Updates expected YAML output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/unassigned.yml Updates expected generate-gitops output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/team-a-thumbsup.yml Updates expected generate-gitops output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/generateGitops/expectedGlobalControls.yaml Updates expected global controls output to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetTeamsYaml.yml Updates expected teams YAML to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetTeamsJson.json Updates expected teams JSON to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml Updates expected config YAML to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json Updates expected config JSON to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml Updates expected app config YAML to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerYaml.yml Updates expected app config (team maintainer) YAML to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerJson.json Updates expected app config (team maintainer) JSON to include deadline_days.
cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigJson.json Updates expected app config JSON to include deadline_days.

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

Comment thread server/service/client.go
Comment thread ee/server/service/mdm.go
Copilot AI review requested due to automatic review settings July 30, 2026 14:20
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Apple OS update settings now support latest with required deadline_days. Specific versions continue to use deadline. Validation, metadata checks, app-config and team change detection, GitOps processing, license gating, declarations, and output expectations were updated for macOS, iOS, and iPadOS. Latest-mode declarations use Fleet host variables.

Possibly related issues

Possibly related PRs

  • fleetdm/fleet#50036 — Uses the same Fleet host variables for per-host Apple OS update handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies issue #48093 and the API/GitOps support for latest Apple OS versions, which matches the primary change.
Description check ✅ Passed The description covers the linked issue and the main applicable validation, testing, QA, GitOps export, and clearing requirements.
Linked Issues check ✅ Passed The changes satisfy [#48093] through latest-version validation, placeholders, variable rejection, activity, API/GitOps support, and premium gating.
Out of Scope Changes check ✅ Passed All production changes, fixtures, schema updates, generated metadata, documentation, and tests support the Apple latest-version API and GitOps objectives in [#48093].
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 48093-auld-api-gitops-latest-os-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/service/client.go (1)

2661-2675: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Include deadline_days when deriving macOS update_new_hosts.

In latest mode, minimum_version and deadline_days are set but deadline is empty, so the current default evaluates to false. This contradicts the comment’s “updates are configured” behavior and disables update enforcement for newly enrolled hosts unless users explicitly set update_new_hosts.

Proposed fix
 		if macOSUpdates["update_new_hosts"] == nil {
-			macOSUpdates["update_new_hosts"] = macOSUpdates["minimum_version"] != "" && macOSUpdates["deadline"] != ""
+			macOSUpdates["update_new_hosts"] = macOSUpdates["minimum_version"] != "" &&
+				(macOSUpdates["deadline"] != "" || macOSUpdates["deadline_days"] != nil)
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/service/client.go` around lines 2661 - 2675, The default derivation of
macOS update_new_hosts incorrectly ignores deadline_days. Update the assignment
in the macOS updates handling block so it defaults to true when minimum_version
and either deadline or deadline_days are configured, while preserving explicit
update_new_hosts values and false when no update settings are configured.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ee/server/service/teams.go`:
- Around line 1434-1444: Update the GitOps MDM validation flow around
MacOSUpdates, IOSUpdates, and IPadOSUpdates to also call
ValidateMDMSettingsAppleSupportedOSVersion for each corresponding platform.
Return the same invalid-argument error pattern when a supported-version check
fails, matching the API path behavior and preventing unsupported minimum_version
values from being persisted.

In `@server/fleet/app.go`:
- Around line 427-446: Update ModifyAppConfig’s AppleOSUpdateSettings patch
handling to clear the stale DeadlineDays value when minimum_version changes away
from "latest", or when both minimum_version and deadline are cleared, before
calling Validate. Preserve explicitly supplied deadline_days and keep
AppleOSUpdateSettings.Validate unchanged for valid latest-update configurations.

In `@server/service/appconfig.go`:
- Around line 1976-1998: Update the shared license-gate error handling after the
platform update flags so the reported field matches the changed platform and
setting: use the iOS or iPadOS field for their respective changes, while
preserving the macOS field for macOS-only changes. Anchor the change to
updatingMacOSDeadlineDays, updatingIOSDeadlineDays, updatingIPadOSDeadlineDays,
and the existing error append logic.

---

Outside diff comments:
In `@server/service/client.go`:
- Around line 2661-2675: The default derivation of macOS update_new_hosts
incorrectly ignores deadline_days. Update the assignment in the macOS updates
handling block so it defaults to true when minimum_version and either deadline
or deadline_days are configured, while preserving explicit update_new_hosts
values and false when no update settings are configured.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fc44f4a3-96ea-4d91-b335-b1689dfd2d5d

📥 Commits

Reviewing files that changed from the base of the PR and between c83ecc2 and a028bc7.

📒 Files selected for processing (31)
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsYaml.yml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/expectedGlobalControls.yaml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/team-a-thumbsup.yml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/unassigned.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigEmpty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigSet.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.yml
  • ee/server/service/mdm.go
  • ee/server/service/mdm_test.go
  • ee/server/service/teams.go
  • ee/server/service/teams_test.go
  • server/fleet/app.go
  • server/fleet/app_test.go
  • server/fleet/mdm.go
  • server/mdm/apple/apple_mdm.go
  • server/mdm/apple/apple_mdm_test.go
  • server/service/appconfig.go
  • server/service/appconfig_test.go
  • server/service/apple_mdm_test.go
  • server/service/client.go
  • server/service/integration_enterprise_test.go

Comment thread ee/server/service/teams.go
Comment thread server/fleet/app.go
Comment thread server/service/appconfig.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Comment thread ee/server/service/mdm.go
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.13%. Comparing base (5e95589) to head (b5da4a3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #50213      +/-   ##
==========================================
- Coverage   68.26%   68.13%   -0.13%     
==========================================
  Files        3949     3934      -15     
  Lines      252481   252239     -242     
  Branches    13291    13361      +70     
==========================================
- Hits       172348   171861     -487     
- Misses      64698    64948     +250     
+ Partials    15435    15430       -5     
Flag Coverage Δ
backend 69.55% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings July 31, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

Suppressed comments (1)

server/service/client.go:2665

  • update_new_hosts default derivation only checks minimum_version and deadline, so in the new "latest" mode (which uses deadline_days and leaves deadline empty) GitOps will incorrectly default update_new_hosts to false whenever it isn't explicitly set. This will silently change behavior when users adopt minimum_version: latest unless they also remember to set update_new_hosts in YAML.
		// Send an explicit null when the file omits deadline_days, otherwise the
		// PATCH would leave a previously stored value in place and the YAML would
		// stop being the source of truth.
		if _, ok := macOSUpdates["deadline_days"]; !ok {
			macOSUpdates["deadline_days"] = nil

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 37 out of 37 changed files in this pull request and generated no new comments.

Suppressed comments (2)

ee/server/service/mdm.go:1504

  • The new "latest"-mode declaration placeholders ($FLEET_VAR_HOST_TARGET_OS_VERSION / ${FLEET_VAR_HOST_TARGET_OS_DEADLINE}) will currently make declaration expansion fail at fetch time: MDMAppleDDMService.replaceDeclarationFleetVariables (server/service/apple_mdm.go:1491-1562) returns an error for any unknown Fleet var, and it has no cases for these new vars. That would cause the OS update declaration to be marked failed and omitted from the manifest.
	targetOSVersion := updates.MinimumVersion.Value
	targetDeadline := updates.Deadline.Value
	var usesFleetVars []fleet.FleetVarName
	if updates.EnforcesLatestVersion() {
		// In "latest" mode the target version and deadline differ per host (they
		// depend on the host's hardware and on when Apple released the version it
		// can run), so emit placeholders that are resolved at declaration fetch
		// time. The deadline placeholder is brace-delimited so it doesn't absorb
		// the time suffix appended below, and resolves to a YYYY-MM-DD date, the
		// same shape as updates.Deadline in specific-version mode.
		targetOSVersion = fmt.Sprintf("$FLEET_VAR_%s", fleet.FleetVarHostTargetOSVersion)
		targetDeadline = fmt.Sprintf("${FLEET_VAR_%s}", fleet.FleetVarHostTargetOSDeadline)
		usesFleetVars = []fleet.FleetVarName{
			fleet.FleetVarHostTargetOSVersion,
			fleet.FleetVarHostTargetOSDeadline,
		}

server/service/appconfig.go:1905

  • This comment is misleading: optjson.String already marshals to null when Valid is false (and existing config JSON includes "deadline": null). Consider rewording to explain why you prefer "" here (e.g., to keep deadline an explicit empty string in latest-mode responses / match existing GitOps behavior), rather than claiming null would be a breaking change.
			// SetString("") rather than the zero value so this still marshals as
			// "" — deadline has always been a string on the wire, and null would
			// be a breaking change for API consumers.

Copilot AI review requested due to automatic review settings August 5, 2026 07:29
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ee/server/service/teams_test.go (1)

1874-1924: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add mode-specific GitOps validation cases for iOS and iPadOS.

The table tests deadline with latest only for macOS. It also does not test deadline_days with a specific version. Add these invalid cases for iOS and iPadOS so each platform preserves both mode-specific restrictions.

As per PR objectives, latest must reject deadline, and specific versions must reject deadline_days.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ee/server/service/teams_test.go` around lines 1874 - 1924, Extend
TestApplyTeamSpecsOSUpdatesValidation with invalid mode-specific cases for both
IOSUpdates and IPadOSUpdates: latest minimum versions paired with a Deadline,
and specific minimum versions paired with DeadlineDays. Set each expected error
to the corresponding platform field key, preserving coverage that latest rejects
deadlines and specific versions reject deadline_days.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ee/server/service/teams_test.go`:
- Around line 1874-1924: Extend TestApplyTeamSpecsOSUpdatesValidation with
invalid mode-specific cases for both IOSUpdates and IPadOSUpdates: latest
minimum versions paired with a Deadline, and specific minimum versions paired
with DeadlineDays. Set each expected error to the corresponding platform field
key, preserving coverage that latest rejects deadlines and specific versions
reject deadline_days.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 17117b10-31f1-4791-96b6-4367acb2db4f

📥 Commits

Reviewing files that changed from the base of the PR and between 33b4efe and 94810d6.

📒 Files selected for processing (38)
  • changes/39085-os-updates-latest-version
  • cmd/fleetctl/fleetctl/gitops_test.go
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsYaml.yml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/expectedGlobalControls.yaml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/team-a-thumbsup.yml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/unassigned.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigEmpty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigSet.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.yml
  • ee/server/service/mdm.go
  • ee/server/service/mdm_test.go
  • ee/server/service/teams.go
  • ee/server/service/teams_test.go
  • server/datastore/mysql/schema.sql
  • server/datastore/mysql/teams_test.go
  • server/fleet/app.go
  • server/fleet/app_test.go
  • server/fleet/mdm.go
  • server/mdm/apple/apple_mdm.go
  • server/mdm/apple/apple_mdm_test.go
  • server/service/appconfig.go
  • server/service/appconfig_test.go
  • server/service/apple_mdm_test.go
  • server/service/client.go
  • server/service/integration_enterprise_test.go
  • tools/cloner-check/generated_files/appconfig.txt
  • tools/cloner-check/generated_files/teamconfig.txt
  • tools/cloner-check/generated_files/teammdm.txt
🚧 Files skipped from review as they are similar to previous changes (30)
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json
  • cmd/fleetctl/fleetctl/gitops_test.go
  • server/mdm/apple/apple_mdm_test.go
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsYaml.yml
  • server/service/apple_mdm_test.go
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerYaml.yml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/unassigned.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.yml
  • server/service/client.go
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigEmpty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigSet.yml
  • cmd/fleetctl/fleetctl/testdata/generateGitops/expectedGlobalControls.yaml
  • ee/server/service/mdm_test.go
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsJson.json
  • server/service/appconfig.go
  • server/fleet/app.go
  • server/fleet/app_test.go
  • server/mdm/apple/apple_mdm.go
  • server/fleet/mdm.go
  • ee/server/service/teams.go
  • server/service/appconfig_test.go
  • server/service/integration_enterprise_test.go
  • ee/server/service/mdm.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated no new comments.

Files excluded by content exclusion policy (1)
  • changes/39085-os-updates-latest-version
Suppressed comments (1)

ee/server/service/mdm.go:1500

  • In "latest" mode this declaration embeds $FLEET_VAR_HOST_TARGET_OS_VERSION / $FLEET_VAR_HOST_TARGET_OS_DEADLINE placeholders, but declaration delivery always runs MDMAppleDDMService.replaceDeclarationFleetVariables for any declaration with VariablesUpdatedAt (server/service/apple_mdm.go:7045-7052). That function currently has no cases for HOST_TARGET_OS_VERSION / HOST_TARGET_OS_DEADLINE and will return an error (server/service/apple_mdm.go:1560-1562), causing the OS update declaration to be marked failed and skipped from the DDM manifest for every host.

This needs an implementation path that resolves these two Fleet vars (ideally only for Fleet’s reserved OS-update declaration) so the manifest generation doesn’t fail in latest mode.

		// time. The deadline placeholder is brace-delimited so it doesn't absorb
		// the time suffix appended below, and resolves to a YYYY-MM-DD date, the
		// same shape as updates.Deadline in specific-version mode.
		targetOSVersion = fmt.Sprintf("$FLEET_VAR_%s", fleet.FleetVarHostTargetOSVersion)
		targetDeadline = fmt.Sprintf("${FLEET_VAR_%s}", fleet.FleetVarHostTargetOSDeadline)

@andymFleet

Copy link
Copy Markdown
Contributor Author

Merged main in to clear the conflicts. The two test-file conflicts were both sides appending new functions at the same spot — kept both.

schema.sql is the one I'd like checked, as it's my first time resolving one: I took main's version and re-added deadline_days to the three Apple objects on the app_config_json seed row. Note it's not added to default_team_config_json, which has the same shape — that matches what this branch's generated schema already had, so I reproduced it rather than "fixing" it. Expected?

Comment thread changes/39085-os-updates-latest-version Outdated
Co-authored-by: Magnus Jensen <magnus@fleetdm.com>
Copilot AI review requested due to automatic review settings August 5, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated no new comments.

Files excluded by content exclusion policy (1)
  • changes/39085-os-updates-latest-version
Suppressed comments (2)

ee/server/service/mdm.go:1504

  • The OS-update declaration now embeds $FLEET_VAR_HOST_TARGET_OS_VERSION / $FLEET_VAR_HOST_TARGET_OS_DEADLINE placeholders in "latest" mode, but declaration expansion currently rejects unknown vars: MDMAppleDDMService.replaceDeclarationFleetVariables falls through to default and returns "Fleet variable ... is not supported in DDM declarations." for these new names. That will cause the reserved OS-update declaration to fail expansion at fetch time and be excluded from the manifest.

To make "latest" mode work, the server-side expander needs explicit support for these vars (likely resolving from host_mdm_apple_os_updates as described in the constant comment in server/fleet/mdm.go), while still rejecting them in admin-supplied declarations.

	if updates.EnforcesLatestVersion() {
		// In "latest" mode the target version and deadline differ per host (they
		// depend on the host's hardware and on when Apple released the version it
		// can run), so emit placeholders that are resolved at declaration fetch
		// time. The deadline placeholder is brace-delimited so it doesn't absorb
		// the time suffix appended below, and resolves to a YYYY-MM-DD date, the
		// same shape as updates.Deadline in specific-version mode.
		targetOSVersion = fmt.Sprintf("$FLEET_VAR_%s", fleet.FleetVarHostTargetOSVersion)
		targetDeadline = fmt.Sprintf("${FLEET_VAR_%s}", fleet.FleetVarHostTargetOSDeadline)
		usesFleetVars = []fleet.FleetVarName{
			fleet.FleetVarHostTargetOSVersion,
			fleet.FleetVarHostTargetOSDeadline,
		}

server/service/appconfig.go:1983

  • This comment claims "deadline has always been a string on the wire", but Fleet config JSON/YAML already represents an unset deadline as null (e.g. default app_config_json in schema.sql). Consider rewording to reflect the actual intent here: clearing to an empty string (instead of leaving it unset/null) for this specific mode switch.

Copilot AI review requested due to automatic review settings August 5, 2026 11:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated no new comments.

Files excluded by content exclusion policy (1)
  • changes/39085-os-updates-latest-version
Suppressed comments (1)

ee/server/service/mdm.go:1503

  • The new OS-update declaration placeholders ($FLEET_VAR_HOST_TARGET_OS_VERSION / ${FLEET_VAR_HOST_TARGET_OS_DEADLINE}) won’t resolve at fetch time with the current code.

Evidence: server/service/apple_mdm.go’s replaceDeclarationFleetVariables switch has no cases for these vars and will hit the default error path ("Fleet variable $FLEET_VAR_%s is not supported in DDM declarations.", around apple_mdm.go:1675-1677). A declaration containing these placeholders will therefore be marked failed and excluded from the DDM manifest.

To make "latest" mode functional, add support in replaceDeclarationFleetVariables to look up the per-host target_os_version and target_deadline (YYYY-MM-DD) from host_mdm_apple_os_updates (schema.sql shows target_os_version and target_deadline columns) and substitute them for these two variables. Validation can still prevent admins from using these vars in user-supplied declarations (as your tests assert).

		targetOSVersion = fmt.Sprintf("$FLEET_VAR_%s", fleet.FleetVarHostTargetOSVersion)
		targetDeadline = fmt.Sprintf("${FLEET_VAR_%s}", fleet.FleetVarHostTargetOSDeadline)
		usesFleetVars = []fleet.FleetVarName{
			fleet.FleetVarHostTargetOSVersion,
			fleet.FleetVarHostTargetOSDeadline,

@andymFleet
andymFleet merged commit 192ac4e into main Aug 5, 2026
51 of 74 checks passed
@andymFleet
andymFleet deleted the 48093-auld-api-gitops-latest-os-version branch August 5, 2026 11:37
@coderabbitai coderabbitai Bot mentioned this pull request Aug 5, 2026
3 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.

AULD: API/Gitops changes for setting latest update version for Apple platforms

4 participants