Skip to content

Add Windows admin account config - #49863

Merged
getvictor merged 14 commits into
mainfrom
victor-48720-windows-managed-local-account
Jul 28, 2026
Merged

Add Windows admin account config#49863
getvictor merged 14 commits into
mainfrom
victor-48720-windows-managed-local-account

Conversation

@getvictor

@getvictor getvictor commented Jul 23, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #48720

Subtask of #43488
This PR only adds the Windows config, and doesn't mess with macOS configs.

Checklist for submitter

  • 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

  • Verified that the setting is exported via fleetctl generate-gitops
  • Verified the setting is documented in a separate PR to the GitOps documentation
  • 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)
  • Verified that any relevant UI is disabled when GitOps mode is enabled

Summary by CodeRabbit

  • New Features

    • Added managed local account settings for Windows to app and team configuration, including GitOps support.
    • Exposed an explicit enabled/disabled toggle in configuration output and Fleet controls.
    • Added licensing and Windows MDM prerequisites for enabling the setting.
  • Bug Fixes

    • Managed local account enable/disable actions are now correctly persisted and declaratively applied.
    • Activity feed messages now display platform-specific (macOS vs Windows) wording.

Copilot AI review requested due to automatic review settings July 23, 2026 20:58
@getvictor

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@getvictor

Copy link
Copy Markdown
Member Author

/agentic_review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

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 a new Windows MDM configuration surface for Fleet’s “managed local admin account” toggle, ensuring it round-trips through API responses, persistence, GitOps apply, and fleetctl generate-gitops, and logs the existing managed-local-account activities when the Windows toggle changes.

Changes:

  • Introduces ManagedLocalAccountSettings{ enabled } and wires it into WindowsSettings, with default-to-false behavior for marshaled output and persisted team/app config.
  • Adds AppConfig PATCH handling: null/absent semantics, premium gating, Windows-MDM precondition validation, and activity logging for Windows toggle changes.
  • Updates GitOps apply/generate to support declarative disable (absent key => disabled), plus adds/updates unit + integration + fleetctl fixture tests.

Reviewed changes

Copilot reviewed 20 out of 20 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 fixtures to include defaulted Windows managed-local-account setting.
server/service/client.go GitOps client defaults Windows toggle to disabled when absent for declarative semantics.
server/service/appconfig.go AppConfig PATCH merge/validate/activity support for Windows managed-local-account toggle.
server/service/appconfig_test.go Adds unit tests covering persistence, gating, activities, and null semantics for Windows toggle.
server/fleet/teams.go Adds team PATCH payload type for Windows toggle and defaults toggle to false for marshal/value/spec output.
server/fleet/teams_test.go Adds tests for team JSON/value defaults and TeamMDM copy behavior for the new setting.
server/fleet/app.go Defines ManagedLocalAccountSettings, adds it to WindowsSettings, and defaults output to enabled=false.
server/fleet/app_test.go Adds tests for AppConfig marshal defaults and clone behavior for the new setting.
ee/server/service/teams.go Adds team PATCH + team-spec apply support for Windows toggle (incl. MDM precondition + activities).
ee/server/service/teams_test.go Adds tests for team PATCH and team-spec apply persistence for Windows toggle.
ee/server/service/mdm.go Renames/refactors activity helper to be platform-agnostic for managed-local-account enable/disable.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.yml Updates expected YAML to include Windows toggle default output.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.yml Updates expected YAML to include Windows toggle default output.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.yml Updates expected YAML to include Windows toggle default output.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.yml Updates expected YAML to include Windows toggle default output.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigSet.yml Updates expected YAML to include Windows toggle default output.
cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigEmpty.yml Updates expected YAML to include Windows toggle default output.
cmd/fleetctl/fleetctl/gitops_test.go Adds end-to-end GitOps test ensuring absent key disables the toggle declaratively.
cmd/fleetctl/fleetctl/generate_gitops.go Emits Windows toggle only when enabled (and premium), to support declarative disable via omission.
cmd/fleetctl/fleetctl/generate_gitops_test.go Adds generate-gitops test coverage for Windows toggle emission rules.
Comments suppressed due to low confidence (1)

ee/server/service/teams.go:416

  • The invalid-argument field path includes an extra "mdm." prefix ("mdm.windows_settings...") whereas other MDM sub-field errors in this handler typically omit the top-level wrapper (e.g. "windows_updates", "setup_experience..."). For this new field, using "windows_settings.managed_local_account_settings.enabled" would better match app-config validation keys and other surfaces.
				return nil, fleet.NewInvalidArgumentError("mdm.windows_settings.managed_local_account_settings.enabled",
					"Couldn't update windows_settings.managed_local_account_settings because Windows MDM isn't turned on in Fleet.")

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

Comment thread ee/server/service/teams.go
Comment thread server/fleet/teams.go
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 23, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. TeamSpecFromTeam mutates input ✓ Resolved 🐞 Bug ☼ Reliability
Description
fleet.TeamSpecFromTeam mutates the caller-provided *Team by writing a default into
t.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled before building the returned spec.
This can cause surprising side effects for callers that reuse the Team object after generating a
spec (e.g., fleetctl get YAML output path).
Code

server/fleet/teams.go[R774-777]

+	if !t.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Valid {
+		t.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled = optjson.SetBool(false)
+	}
mdmSpec.WindowsSettings = t.Config.MDM.WindowsSettings
Evidence
The function writes directly into the input pointer (t.Config... = optjson.SetBool(false)), and it
is called with a pointer from fleetctl when building a team spec for YAML output, making the
mutation observable beyond the function scope.

server/fleet/teams.go[748-801]
cmd/fleetctl/fleetctl/get.go[271-303]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`fleet.TeamSpecFromTeam` should behave like a pure conversion helper, but it currently mutates the provided `*Team` by setting a default on `t.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled`.
## Issue Context
This is a side effect on a pointer argument and can leak out to callers that reuse `*Team` after calling `TeamSpecFromTeam`.
## Fix Focus Areas
- server/fleet/teams.go[774-777]
## Suggested fix
Do not write back into `t.Config`. Instead, copy `t.Config.MDM.WindowsSettings` into a local variable, default the local copy if needed, and assign that to `mdmSpec.WindowsSettings`.
Example approach:
- `ws := t.Config.MDM.WindowsSettings`
- If `!ws.ManagedLocalAccountSettings.Enabled.Valid`, set it to `optjson.SetBool(false)`
- `mdmSpec.WindowsSettings = ws`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Windows toggle error path ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
ModifyTeam returns an InvalidArgumentError keyed as
"mdm.windows_settings.managed_local_account_settings.enabled", which is inconsistent with other team
MDM error keys in the same method (e.g., "windows_updates" and "setup_experience.*"). This
inconsistency increases the risk of mismatched field-level error association across consumers.
Code

ee/server/service/teams.go[R411-417]

+		if payload.MDM.WindowsSettings != nil && payload.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Valid {
+			newEnabled := payload.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled
+			windowsManagedLocalAccountUpdated = team.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Value != newEnabled.Value
+			if windowsManagedLocalAccountUpdated && newEnabled.Value && !appCfg.MDM.WindowsEnabledAndConfigured {
+				return nil, fleet.NewInvalidArgumentError("mdm.windows_settings.managed_local_account_settings.enabled",
+					"Couldn't update windows_settings.managed_local_account_settings because Windows MDM isn't turned on in Fleet.")
+			}
Evidence
The newly added error key is the only occurrence of the mdm.windows_settings... path, while other
Windows MDM-related errors in the same method use unprefixed keys like windows_updates,
demonstrating inconsistency introduced by this change.

ee/server/service/teams.go[299-340]
ee/server/service/teams.go[411-419]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `ModifyTeam` validation error uses the field path `mdm.windows_settings.managed_local_account_settings.enabled`, which is inconsistent with other team MDM error keys used nearby.
## Issue Context
Within `ModifyTeam`, other errors use keys like `windows_updates` and `setup_experience.*`. For the same Windows managed-local-account toggle, the team-spec/app-config paths elsewhere also use `windows_settings.managed_local_account_settings.enabled` (without the `mdm.` prefix).
## Fix Focus Areas
- ee/server/service/teams.go[411-417]
## Suggested fix
Pick one canonical key format for this endpoint and apply it consistently. If following the existing Windows MDM key style in `ModifyTeam`, rename the error key to `windows_settings.managed_local_account_settings.enabled` (dropping the `mdm.` prefix), and update/extend tests if any assert on the key.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread server/fleet/teams.go Outdated
Comment thread ee/server/service/teams.go
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c3cfe020-c68c-4a97-b0cf-a2bcc0022bed

📥 Commits

Reviewing files that changed from the base of the PR and between 30be734 and d2d901b.

📒 Files selected for processing (3)
  • cmd/fleetctl/fleetctl/generate_gitops.go
  • ee/server/service/mdm.go
  • ee/server/service/teams.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/fleetctl/fleetctl/generate_gitops.go
  • ee/server/service/teams.go
  • ee/server/service/mdm.go

Walkthrough

Adds Windows managed local account settings to Fleet configuration models, API payloads, serialization, validation, team PATCH, GitOps application, and GitOps generation. Enabling is gated by premium licensing and configured Windows MDM. Configuration changes emit platform-specific activities, and the activity feed renders Windows or macOS host labels while preserving the macOS fallback for legacy events. Tests and expected configuration fixtures cover default-disabled serialization, enable/disable transitions, validation, persistence, and generated output.

Possibly related issues

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The schema.sql seed change to logger_tls_endpoint is unrelated to Windows admin-account config and appears out of scope. Remove the unrelated schema default change or split it into a separate PR focused on that datastore update.
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: adding Windows admin account config.
Description check ✅ Passed The description includes the related issue, key scope note, and the completed checklist items required by the template.
Linked Issues check ✅ Passed The PR implements the Windows managed-local-account config, GitOps, licensing, activity logging, and test coverage required by #48720.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch victor-48720-windows-managed-local-account

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: 1

🤖 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 2013-2022: Update the edit handling around
ManagedLocalAccountSettings.Enabled in the team configuration flow to default an
omitted GitOps toggle to false, while preserving explicit values and existing
validation for enabling it. Ensure the assignment and update tracking treat the
omitted field as a disable operation, and add an edit test beginning with the
setting enabled and omitting the field to verify it becomes false.
🪄 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: e7e23154-418c-4900-99ee-3507cce03cc1

📥 Commits

Reviewing files that changed from the base of the PR and between 9cfd907 and 2f15bf0.

📒 Files selected for processing (20)
  • cmd/fleetctl/fleetctl/generate_gitops.go
  • cmd/fleetctl/fleetctl/generate_gitops_test.go
  • cmd/fleetctl/fleetctl/gitops_test.go
  • 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/teams.go
  • ee/server/service/teams_test.go
  • server/fleet/app.go
  • server/fleet/app_test.go
  • server/fleet/teams.go
  • server/fleet/teams_test.go
  • server/service/appconfig.go
  • server/service/appconfig_test.go
  • server/service/client.go
  • server/service/integration_enterprise_test.go

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

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.72289% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.00%. Comparing base (eedfc56) to head (d2d901b).
⚠️ Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
ee/server/service/teams.go 64.51% 7 Missing and 4 partials ⚠️
ee/server/service/mdm.go 75.00% 1 Missing and 1 partial ⚠️
server/service/appconfig.go 91.66% 1 Missing and 1 partial ⚠️
...vityFeed/GlobalActivityItem/GlobalActivityItem.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #49863      +/-   ##
==========================================
+ Coverage   67.92%   68.00%   +0.07%     
==========================================
  Files        3906     3925      +19     
  Lines      249746   250239     +493     
  Branches    13337    13367      +30     
==========================================
+ Hits       169649   170165     +516     
+ Misses      64822    64761      -61     
- Partials    15275    15313      +38     
Flag Coverage Δ
backend 69.38% <81.01%> (+0.05%) ⬆️
frontend 60.57% <75.00%> (+0.15%) ⬆️

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 23, 2026 21:47

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 20 out of 20 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

ee/server/service/teams.go:1561

  • This error message refers to enabling windows_settings.managed_local_account_settings, but the actual setting is the enabled field. Using the full field path in the message avoids confusion when troubleshooting spec-apply failures.
	if spec.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Value && !windowsEnabledAndConfigured {
		return nil, ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError("windows_settings.managed_local_account_settings.enabled",
			"Couldn't enable windows_settings.managed_local_account_settings. "+fleet.ErrWindowsMDMNotConfigured.Error()))
	}

ee/server/service/teams.go:2020

  • This error message refers to enabling windows_settings.managed_local_account_settings, but the invalid-argument key is windows_settings.managed_local_account_settings.enabled. Updating the message to match the field path will make the error clearer.
		if didUpdateWindowsManagedLocalAccount && newWindowsManagedLocalAccount.Value && !windowsEnabledAndConfigured {
			return ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError("windows_settings.managed_local_account_settings.enabled",
				"Couldn't enable windows_settings.managed_local_account_settings. "+fleet.ErrWindowsMDMNotConfigured.Error()))
		}

Comment thread ee/server/service/teams.go
Comment thread server/service/appconfig.go
Copilot AI review requested due to automatic review settings July 24, 2026 14:51

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 20 out of 20 changed files in this pull request and generated 2 comments.

Comment thread server/service/appconfig.go Outdated
Comment thread cmd/fleetctl/fleetctl/generate_gitops.go Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 14:59

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 20 out of 20 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

cmd/fleetctl/fleetctl/generate_gitops.go:1381

  • Avoid embedding a specific date in this inline comment. Dates become stale quickly and don’t communicate durable intent; prefer a timeless rationale and/or an issue reference for why disabled settings aren’t emitted.
			// emit the managed local account toggle only when enabled
			// Product guidance (2026/07/24): we generally do not output all settings, only what's configured
			if cmd.AppConfig.License.IsPremium() && teamMdm != nil && teamMdm.WindowsSettings.ManagedLocalAccountSettings.Enabled.Value {

server/service/appconfig.go:1988

  • The error message says it couldn’t enable "windows_settings.managed_local_account_settings" but the validated field/key is "windows_settings.managed_local_account_settings.enabled". Using the full field path here makes the response clearer and consistent with the invalid-argument key.
			invalid.Append("windows_settings.managed_local_account_settings.enabled",
				`Couldn’t enable windows_settings.managed_local_account_settings. Windows MDM isn’t turned on. This can be enabled by setting "controls.windows_enabled_and_configured: true" in the default configuration. Visit https://fleetdm.com/guides/windows-mdm-setup and https://fleetdm.com/docs/configuration/yaml-files#controls to learn more about enabling MDM.`)
		}

Comment thread cmd/fleetctl/fleetctl/gitops_test.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.

Pull request overview

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

Comments suppressed due to low confidence (2)

ee/server/service/teams.go:426

  • Team PATCH path allows enabling Windows managed local account without any premium-license gate. This lets a Free-tier instance turn on a premium-only feature via /teams/:id, unlike the global /config path which enforces ErrMissingLicense when enabling.
		if payload.MDM.WindowsSettings != nil && payload.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Valid {
			newEnabled := payload.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled
			windowsManagedLocalAccountUpdated = team.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Value != newEnabled.Value
			if windowsManagedLocalAccountUpdated && newEnabled.Value && !appCfg.MDM.WindowsEnabledAndConfigured {
				return nil, fleet.NewInvalidArgumentError("windows_settings.managed_local_account_settings.enabled",
					"Couldn't update windows_settings.managed_local_account_settings because Windows MDM isn't turned on in Fleet.")
			}
			team.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled = newEnabled
		}

ee/server/service/teams.go:2019

  • GitOps/team-spec apply path (editTeamFromSpec) enables the Windows managed local account toggle without checking for a premium license. This makes license enforcement inconsistent with ModifyAppConfig/validateMDM and allows enabling the feature via fleetctl gitops on a Free-tier instance.
	var didUpdateWindowsManagedLocalAccount bool
	if spec.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Valid {
		newWindowsManagedLocalAccount := spec.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled
		didUpdateWindowsManagedLocalAccount = team.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled.Value != newWindowsManagedLocalAccount.Value
		if didUpdateWindowsManagedLocalAccount && newWindowsManagedLocalAccount.Value && !windowsEnabledAndConfigured {
			return ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError("windows_settings.managed_local_account_settings.enabled",
				"Couldn't enable windows_settings.managed_local_account_settings. "+fleet.ErrWindowsMDMNotConfigured.Error()))
		}
		team.Config.MDM.WindowsSettings.ManagedLocalAccountSettings.Enabled = newWindowsManagedLocalAccount
	}

@getvictor
getvictor marked this pull request as ready for review July 24, 2026 20:52
@getvictor
getvictor requested review from a team as code owners July 24, 2026 20:52
@getvictor
getvictor requested a review from lucasmrod July 24, 2026 20:54
@getvictor

Copy link
Copy Markdown
Member Author

@lucasmrod, assigning this one to you to review for Monday. Feel free to assign PRs to me to review, since I don't have another engineer on my team right now.

@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: 1

Caution

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

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

418-425: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Enforce premium licensing before enabling the team-level setting.

Both paths allow a free-tier deployment with configured Windows MDM to enable this premium capability. Gate only false→true transitions; disabling must remain allowed for license downgrades.

  • ee/server/service/teams.go#L418-L425: require premium entitlement before persisting an enabled PATCH value.
  • ee/server/service/teams.go#L2010-L2019: apply the same entitlement check during GitOps team edits.
🤖 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.go` around lines 418 - 425, The team-level Windows
managed local account setting must require premium entitlement only for
false-to-true transitions. In ee/server/service/teams.go:418-425, update the
PATCH handling around the WindowsSettings managed-local-account Enabled
assignment to reject enabling when the deployment lacks the premium entitlement,
while preserving disabling and existing Windows MDM validation. Apply the same
entitlement check to the GitOps team-edit path in
ee/server/service/teams.go:2010-2019 before persisting an enabled value; no
restriction should apply when disabling.
🧹 Nitpick comments (1)
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx (1)

722-745: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the legacy fallback for enabled activities too.

The legacy case at Line 737 uses DisabledManagedLocalAccount, so enabledManagedLocalAccount is never tested when details.platform is absent. Add an enabled legacy assertion and keep the disabled case separately.

🤖 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
`@frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx`
around lines 722 - 745, Update the test around the enabledManagedLocalAccount
activity to add a legacy enabled activity with empty details and assert it
defaults to macOS. Keep the existing Windows assertion, and retain the disabled
legacy activity as a separate case so both activity types’ fallbacks are
covered.
🤖 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 `@server/service/integration_enterprise_test.go`:
- Around line 221-229: Update TeamConfig.Value() to normalize Windows
managed-local-account settings alongside the existing macOS defaults: when
ManagedLocalAccountSettings.Enabled is not valid, assign optjson.SetBool(false)
before serialization. Preserve explicitly configured Windows values and apply
the same normalization consistently across the affected TeamConfig.Value()
paths.

---

Outside diff comments:
In `@ee/server/service/teams.go`:
- Around line 418-425: The team-level Windows managed local account setting must
require premium entitlement only for false-to-true transitions. In
ee/server/service/teams.go:418-425, update the PATCH handling around the
WindowsSettings managed-local-account Enabled assignment to reject enabling when
the deployment lacks the premium entitlement, while preserving disabling and
existing Windows MDM validation. Apply the same entitlement check to the GitOps
team-edit path in ee/server/service/teams.go:2010-2019 before persisting an
enabled value; no restriction should apply when disabling.

---

Nitpick comments:
In
`@frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx`:
- Around line 722-745: Update the test around the enabledManagedLocalAccount
activity to add a legacy enabled activity with empty details and assert it
defaults to macOS. Keep the existing Windows assertion, and retain the disabled
legacy activity as a separate case so both activity types’ fallbacks are
covered.
🪄 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: f2011994-32a9-4198-bba7-f032094e09a5

📥 Commits

Reviewing files that changed from the base of the PR and between 2f15bf0 and 30be734.

📒 Files selected for processing (32)
  • cmd/fleetctl/fleetctl/apply_deprecated_test.go
  • cmd/fleetctl/fleetctl/apply_test.go
  • cmd/fleetctl/fleetctl/generate_gitops.go
  • cmd/fleetctl/fleetctl/generate_gitops_test.go
  • 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
  • ee/server/service/mdm.go
  • ee/server/service/teams.go
  • ee/server/service/teams_test.go
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • server/datastore/mysql/schema.sql
  • server/datastore/mysql/teams_test.go
  • server/fleet/activities.go
  • server/fleet/app.go
  • server/fleet/app_test.go
  • server/fleet/mdm.go
  • server/fleet/teams.go
  • server/service/appconfig.go
  • server/service/appconfig_test.go
  • server/service/integration_enterprise_test.go
  • server/service/integration_mdm_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 (3)
  • ee/server/service/mdm.go
  • cmd/fleetctl/fleetctl/generate_gitops.go
  • ee/server/service/teams_test.go

Comment thread server/service/integration_enterprise_test.go

@lucasmrod lucasmrod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Left two questions.

Comment thread cmd/fleetctl/fleetctl/generate_gitops.go Outdated
Comment thread ee/server/service/teams.go
Copilot AI review requested due to automatic review settings July 28, 2026 14:54
@getvictor
getvictor requested a review from lucasmrod July 28, 2026 15:04

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 38 out of 38 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

ee/server/service/teams.go:424

  • The Windows MDM precondition error message is inconsistent with the rest of the API and doesn’t mention the actual leaf key (...enabled). It also omits the standard guidance used elsewhere (see fleet.WindowsMDMNotTurnedOnMessage).
			if windowsManagedLocalAccountUpdated && newEnabled.Value && !appCfg.MDM.WindowsEnabledAndConfigured {
				return nil, fleet.NewInvalidArgumentError("windows_settings.managed_local_account_settings.enabled",
					"Couldn't update windows_settings.managed_local_account_settings because Windows MDM isn't turned on in Fleet.")
			}

ee/server/service/teams.go:2017

  • This GitOps/team-spec validation error message uses a different Windows-MDM-not-configured message than ModifyAppConfig/validateMDM, and it also refers to managed_local_account_settings instead of the actual leaf key managed_local_account_settings.enabled. Consider reusing fleet.WindowsMDMNotTurnedOnMessage for consistent guidance and error text.
		if didUpdateWindowsManagedLocalAccount && newWindowsManagedLocalAccount.Value && !windowsEnabledAndConfigured {
			return ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError("windows_settings.managed_local_account_settings.enabled",
				"Couldn't enable windows_settings.managed_local_account_settings. "+fleet.ErrWindowsMDMNotConfigured.Error()))
		}

server/service/appconfig.go:1985

  • The invalid-argument message mentions windows_settings.managed_local_account_settings, but the rejected field is windows_settings.managed_local_account_settings.enabled. Aligning the message with the actual leaf key makes the error clearer (and matches other MDM validation messages).

@getvictor

Copy link
Copy Markdown
Member Author

@lucasmrod I made fixes for your 2 comments. Ready for re-review.

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.

Windows local admin account: managed_local_account_settings config surface and GitOps

4 participants