Skip to content

Accept name and description on profile endpoints - #54195

Merged
jbelbo merged 20 commits into
mainfrom
jbelbo/51814-profile-name-api
Sep 30, 2026
Merged

jbelbo merged 20 commits into
mainfrom
jbelbo/51814-profile-name-api

Conversation

@jbelbo

@jbelbo jbelbo commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Related issue: #51814

Second of four stacked PRs for #51814, based on #54006 (the description column). This one exposes name and description through the API. GitOps support and the new add/edit page follow in the next two PRs.

What

  • Create (POST /configuration_profiles) accepts optional name and description. Without name, the name is derived as before: PayloadDisplayName for .mobileconfig, the file name for .xml and .json.
  • Update (PATCH /configuration_profiles/:uuid) accepts name and description. An absent name leaves the name unchanged, even when a new file is uploaded; a replacement file no longer renames the profile. An absent description keeps it, and an empty one clears it.
  • Batch (POST /configuration_profiles/batch and the contributor /mdm/profiles/batch) accept name and description. display_name stays as a deprecated alias of name: both present and different is a 400, and on its own it's still ignored for .mobileconfig profiles, as documented. The batch replaces the whole set, so an omitted description is cleared, like labels.
  • List and get return description, and payload_display_name for .mobileconfig profiles, since the stored name can now differ from it.
  • Validation, shared by all three: the name is trimmed and non-empty, up to 255 characters, not a Fleet-reserved name, and without $FLEET_SECRET_ variables. The description is up to 1,023 characters. Windows keeps its existing 400 responses for reserved and over-long names, and Android for reserved names. An over-long derived name, like a long PayloadDisplayName, is now a 422 instead of a database error.
  • Uniqueness: names were already unique per fleet across all four profile types. Rename paths now check the other tables in the same statement, so the check and the write are atomic.
  • No re-delivery on rename: changing only the name or description doesn't bump uploaded_at or checksums, even when the same file is resent with the new name, so profiles aren't resent or re-verified. For declarations this also keeps the hosts' DDM token stable, since it's ordered by uploaded_at. Host details read the live profile name through a join, so a rename shows up there without rewriting host rows.

Steps to reproduce

On main, a profile's name can only change by uploading a new file, and uploading a replacement .mobileconfig or .xml renames it as a side effect:

  1. Upload a .mobileconfig whose PayloadDisplayName is "A".
  2. PATCH it with the same PayloadIdentifier and PayloadDisplayName "B". The profile is renamed to "B".

With this PR, step 2 keeps the name "A", and PATCH with name=B renames it without a new file.

How I tested

  • MYSQL_TEST=1 REDIS_TEST=1 go test ./server/service/ -run 'TestIntegrationsMDM/(TestConfigProfileNameAndDescription|TestUpdateConfigProfile|TestBatchSetMDMProfiles|TestBatchModifyMDMProfiles|TestMDMConfigProfileCRUD|TestListMDMConfigProfiles|TestBatchSetMDMProfilesBackwardsCompat)$' passes. TestConfigProfileNameAndDescription covers create, update and batch for every profile type, validation, the display_name alias and trimming.
  • MYSQL_TEST=1 go test ./server/datastore/mysql/ -run 'TestMDMShared|TestMDMApple|TestAndroid|TestMicrosoftMDM|TestMDMWindows' passes, including renames that must not bump uploaded_at and host details showing the new name.
  • Service unit tests, go test ./server/fleet/, and make lint-go-incremental pass.
  • Manually tested with the rest of the stack in the browser against a local server with Apple and Windows MDM.
  • Not tested: Android end to end, since the local server has no Android MDM. Covered by the datastore and service tests.

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

  • 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.

  • If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes
    No paths change. The rename-on-replace behavior of PATCH changes as agreed in Add/edit configuration profile page w/ upload #51814.

Testing

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Add names and descriptions to Apple, Windows, and Android configuration profiles when creating or updating them, including through batch APIs.
    • Rename profiles without replacing their contents. Profile lists and details show descriptions and, for Apple mobileconfig profiles, the payload display name.
    • Profile uploads retain the existing name when no new name is provided; batch requests continue to accept the legacy display_name field.
  • Bug Fixes

    • Reject invalid or conflicting profile names and overlong descriptions. Metadata-only changes leave upload timestamps unchanged.
    • Show updated profile names on hosts after a rename, and retain the host’s stored name when the profile is deleted. Certain GitOps renames recreate profiles and cause hosts to reinstall them.

Stored for all four profile types and returned by list and get. Not
part of any checksum or token, and the update paths leave uploaded_at
alone on a description-only change, so editing it never re-delivers
the profile. Setting it through the API, GitOps and the UI follows.

Related issue: #51814
The Apple-only list and identifier lookups now select description. The
batch payload stops accepting it from JSON until the API change adds
its length validation.
Bumped the migration past the newest one on main.
Create, update and batch take an explicit name and description for
every profile type. A replacement file no longer renames the profile
unless name is sent, and display_name on the public batch endpoint
becomes an alias of name. List and get return description, plus
payload_display_name for mobileconfigs so the UI can show both.

Related issue: #51814
@jbelbo
jbelbo requested a lite review from Copilot September 28, 2026 14:13
@jbelbo

jbelbo commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

/agentic_review

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.

Copilot review overview

🟡 Changes recommended

Unresolved validation, uniqueness, and metadata-only update issues can cause incorrect persistence or unnecessary redelivery.

Review effort: Lite
Findings: 5 Medium severity · 1 Low severity

Open (6)
What changed in this PR

This PR adds name and description support to configuration profile APIs, including validation, renaming, listing, and batch operations across MDM platforms.

Changes:

  • Adds metadata handling for create, update, batch, list, and get flows.
  • Adds payload display names, compatibility handling, and datastore persistence updates.
  • Updates validation, host lookups, mocks, tests, and release notes.
File Description
server/​service/​windows_mdm_profiles.go Windows profile metadata handling
server/​service/​windows_mdm_profiles_test.go Windows service tests
server/​service/​mdm.go API decoding, validation, and batch handling
server/​service/​mdm_test.go Service tests
server/​service/​integration_mdm_test.go Integration coverage
server/​service/​integration_mdm_profiles_test.go Profile CRUD and batch tests
server/​service/​apple_mdm.go Apple profile metadata handling
server/​service/​apple_mdm_test.go Apple service tests
server/​mock/​service/​service_mock.go Updated service mocks
server/​fleet/​service.go Service interface updates
server/​fleet/​mdm.go Profile payloads and validation
server/​fleet/​mdm_test.go Validation and display-name tests
server/​fleet/​apple_mdm.go Payload display-name extraction
server/​fleet/​android.go Android name validation
server/​datastore/​mysql/​microsoft_mdm.go Windows persistence and uniqueness
server/​datastore/​mysql/​mdm.go Profile listing and batch persistence
server/​datastore/​mysql/​mdm_test.go Datastore rename tests
server/​datastore/​mysql/​apple_mdm.go Apple persistence and host updates
server/​datastore/​mysql/​android.go Android persistence and rename updates
server/​datastore/​mysql/​android_test.go Android rename tests
changes/​51814-profile-description User-facing change entry

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread server/datastore/mysql/apple_mdm.go Resolved
Comment thread server/datastore/mysql/apple_mdm.go Resolved
Comment thread server/service/mdm.go Resolved
Comment thread server/service/mdm.go Resolved
Comment thread server/service/mdm.go
Comment on lines +3580 to +3584
if profile.Name != "" {
if err := fleet.ValidateMDMProfileName(profile.Name); err != nil {
return fleet.NewInvalidArgumentError("mdm", "Couldn't edit configuration_profiles. "+err.Error())
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a193c96: getAppleProfiles now checks the final name, including one taken from PayloadDisplayName, against the 255-character limit and returns a validation error. Android batch names always come from the request, so the existing check already covers them.

Comment thread server/service/integration_mdm_test.go Resolved
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Batch users cannot trim a profile name 🐞 Bug ≡ Correctness
Description
getAppleProfiles ignores an explicit name when it equals the trimmed PayloadDisplayName, leaving
the untrimmed payload value as the stored name. For a mobileconfig with PayloadDisplayName set to
" A ", a batch request specifying name: "A" stores " A " instead.
Code

server/service/mdm.go[R3362-3364]

+		if prof.Name != "" && prof.Name != strings.TrimSpace(mdmProf.Name) {
+			mdmProf.Name = prof.Name
+		}
Evidence
The constructor stores PayloadDisplayName verbatim, while the new equality test skips the override
for its trimmed value.

server/fleet/apple_mdm.go[317-325]
server/service/mdm.go[3359-3364]

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

## Issue description
Batch requests cannot explicitly set a mobileconfig name to the trimmed version of its PayloadDisplayName.
## Fix Focus Areas
- server/service/mdm.go[3359-3364]
- server/fleet/apple_mdm.go[317-325]
## Recommended Fix
Carry whether the batch name was explicitly supplied through parsing, and apply every explicit name to the constructed profile. Preserve the legacy fleetctl-derived-name behavior only when the name was not explicit.

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


2. Apple renames with a file trigger rechecks ✓ Resolved
Description
UpdateMDMAppleConfigProfile preserves uploaded_at only when both checksum and name are
unchanged. When an edit supplies a new name alongside an unchanged mobileconfig, the timestamp
advances even though the batch path now treats that rename as metadata-only.
Code

server/service/apple_mdm.go[1967]

+		cp, varNames, _, err = svc.parseAndValidateAppleConfigProfile(ctx, teamID, name, profile, labelsInclude, labelsMembershipMode, labelsExcludeAny)
Evidence
The changed service path passes the selected name with uploaded content; the single-update SQL
includes name in its timestamp condition, unlike the changed batch rule.

server/service/apple_mdm.go[1952-1955]
server/service/apple_mdm.go[1964-1969]
server/datastore/mysql/apple_mdm.go[362-368]
server/datastore/mysql/apple_mdm.go[2997-3004]

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

## Issue description
Sending an unchanged mobileconfig with a new name advances the profile's upload timestamp.
## Fix Focus Areas
- server/service/apple_mdm.go[1964-1969]
- server/datastore/mysql/apple_mdm.go[362-368]
## Recommended Fix
In the single-profile content update, preserve uploaded_at when the mobileconfig checksum is unchanged regardless of the new name, matching the batch upsert rule. Add a test that renames while resending identical content.

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


3. Windows renames with a file look new ✓ Resolved
Description
UpdateMDMWindowsConfigProfile advances uploaded_at when nameChanged is true, even if the
replacement XML matches the stored bytes. The new update path passes the requested name with
uploaded content, so resending an unchanged file during a rename takes that branch rather than the
metadata-only branch.
Code

server/service/windows_mdm_profiles.go[226]

+		cp, usesFleetVars, _, err = svc.parseAndValidateWindowsConfigProfile(ctx, teamID, name, profile, labelsInclude, labelsMembershipMode, labelsExcludeAny, "Couldn't edit. ")
Evidence
The changed service call supplies the chosen name with a replacement file; the datastore explicitly
includes nameChanged in the timestamp-update condition.

server/service/windows_mdm_profiles.go[211-226]
server/datastore/mysql/microsoft_mdm.go[3318-3341]
server/datastore/mysql/microsoft_mdm.go[3410-3416]

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

## Issue description
A Windows rename accompanied by unchanged XML advances uploaded_at.
## Fix Focus Areas
- server/service/windows_mdm_profiles.go[223-229]
- server/datastore/mysql/microsoft_mdm.go[3318-3341]
## Recommended Fix
In the Windows content-update branch, advance uploaded_at only when the XML bytes change, not when only the name changes. Add a rename test that resends identical XML.

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


View medium (1)
4. Renaming a DDM profile re-syncs every host ✓ Resolved
Description
SetOrUpdateMDMAppleDeclaration advances uploaded_at when a declaration’s name changes, and the
batch declaration upsert has the same condition. A rename-only PATCH with unchanged JSON reaches
that upsert, changing the MDMAppleDDMDeclarationsToken for every targeted host because the token
orders declarations by uploaded_at, so those hosts start a new DDM sync.
Code

server/datastore/mysql/apple_mdm.go[R5463-5464]

uploaded_at = IF(raw_json = VALUES(raw_json) AND name = VALUES(name) AND IFNULL(secrets_updated_at = VALUES(secrets_updated_at), TRUE), uploaded_at, NOW(6)),
+	name = VALUES(name),
Evidence
The new service rename path passes the renamed declaration to SetOrUpdateMDMAppleDeclaration,
whose upsert advances uploaded_at on a name difference even without replacement JSON. The per-host
reconciliation token uses a GROUP_CONCAT ordered by mad.uploaded_at, connecting that timestamp
change to the token change; the PR test acknowledges the upload bump but checks only that Token is
unchanged. The batch declaration upsert has the same name-dependent condition.

server/datastore/mysql/apple_mdm.go[5459-5466]
server/datastore/mysql/apple_mdm.go[5974-5985]
server/datastore/mysql/mdm_test.go[2140-2142]
server/service/apple_mdm.go[1187-1193]
server/service/apple_mdm.go[1233-1238]
server/service/apple_mdm.go[1277-1285]
server/datastore/mysql/apple_mdm.go[5461-5465]
server/datastore/mysql/apple_mdm.go[5975-5980]

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

## Issue description
A rename-only declaration update advances `uploaded_at`, changing the hosts’ DDM reconciliation token and causing targeted hosts to start a new sync despite unchanged JSON.
## Fix Focus Areas
- server/service/apple_mdm.go[1187-1193]
- server/service/apple_mdm.go[1233-1238]
- server/datastore/mysql/apple_mdm.go[5461-5465]
- server/datastore/mysql/apple_mdm.go[5269-5269]
## Recommended Fix
Remove `AND name = VALUES(name)` from the `uploaded_at` condition in both declaration upserts, as was done for the mobileconfig batch upsert at line 3001, so a name-only change does not advance the timestamp. Add a test for a declaration rename with unchanged JSON that verifies `uploaded_at` remains unchanged.

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



Informational

5. Declaration renames scan the host table ✓ Resolved
Description
The new UPDATE host_mdm_apple_declarations ... WHERE declaration_uuid = ? has no index to use,
because the primary key starts with host_uuid, so every rename scans the whole table and locks rows
inside the upsert transaction. The rewrite is also redundant: GetHostMDMAppleProfiles now reads the
live name through a join.
Code

server/datastore/mysql/apple_mdm.go[R5566-5570]

+		if renamed {
+			if _, err := tx.ExecContext(ctx,
+				`UPDATE host_mdm_apple_declarations SET declaration_name = ? WHERE declaration_uuid = ?`,
+				declaration.Name, declUUID); err != nil {
+				return ctxerr.Wrap(ctx, err, "update host declaration names")
Evidence
In schema.sql the table's primary key is (host_uuid, declaration_uuid) and no other key starts with
declaration_uuid, so the UPDATE cannot use an index. The new join in GetHostMDMAppleProfiles already
returns the live declaration name, which makes the rewrite unnecessary.

server/datastore/mysql/schema.sql[1083-1103]
server/datastore/mysql/apple_mdm.go[1063-1081]

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

## Issue description
After a declaration rename, the name is rewritten on every host row with an UPDATE filtered on declaration_uuid, which has no index, so the UPDATE scans the whole table.
## Fix Focus Areas
- server/datastore/mysql/apple_mdm.go[5563-5572]
## Recommended Fix
Delete the rewrite and rely on the COALESCE(mad.name, hmad.declaration_name) join in GetHostMDMAppleProfiles. If the stored copy must stay current, add an index on declaration_uuid first.

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


Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread server/service/mdm.go
Comment on lines +3362 to +3364
if prof.Name != "" && prof.Name != strings.TrimSpace(mdmProf.Name) {
mdmProf.Name = prof.Name
}

@qodo-free-for-open-source-projects qodo-free-for-open-source-projects Bot Sep 28, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Batch users cannot trim a profile name 🐞 Bug ≡ Correctness


getAppleProfiles ignores an explicit name when it equals the trimmed PayloadDisplayName, leaving
the untrimmed payload value as the stored name. For a mobileconfig with PayloadDisplayName set to
" A ", a batch request specifying name: "A" stores " A " instead.
Agent Prompt
## Issue description
Batch requests cannot explicitly set a mobileconfig name to the trimmed version of its PayloadDisplayName.
## Fix Focus Areas
- server/service/mdm.go[3359-3364]
- server/fleet/apple_mdm.go[317-325]
## Recommended Fix
Carry whether the batch name was explicitly supplied through parsing, and apply every explicit name to the constructed profile. Preserve the legacy fleetctl-derived-name behavior only when the name was not explicit.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is intentional, and main behaves the same way, it ignores the batch name for a .mobileconfig entirely. fleetctl sends the trimmed PayloadDisplayName as the name, so honoring it would rename profiles stored with whitespace on the first GitOps run after upgrade.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dismissed — intentional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hey @getvictor , what do you think about this one? The server ignores a batch name that equals the trimmed PayloadDisplayName, so fleetctl doesn't rename a profile like " Wi-Fi " on the first GitOps run after upgrade. The cost is that name: Wi-Fi can't be set on that profile from YAML.

The alternative is to trim PayloadDisplayName when storing, as qodo suggests here. It's safe now that a rename isn't re-sent, but a fleet that already has both " Wi-Fi " and "Wi-Fi" would collide. I was initially planning to leave it like this but would like your input.

Comment thread server/service/apple_mdm.go Resolved
Comment thread server/service/windows_mdm_profiles.go Resolved
Comment thread server/datastore/mysql/apple_mdm.go Resolved
Comment thread server/datastore/mysql/apple_mdm.go Resolved

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.

Copilot review overview

🟡 Changes recommended

Unresolved issues affect Android redelivery, name normalization, validation compatibility, and HTTP status behavior.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
Resolved since last review (5)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Return HTTP 400 for conflicting name and display_name

server/​service/​mdm.go:2743

This conflict is returned as a plain InvalidArgumentError, whose endpoint status is 422, and the integration test below explicitly expects http.StatusUnprocessableEntity. The PR description specifies that providing different name and display_name values is a 400; either set http.StatusBadRequest here or correct the stated API contract and tests.

Comment thread server/service/mdm.go
}
cp.ProfileUUID = profileUUID
cp.Description = existing.Description
cp.Description = newDescription

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This doesn't re-deliver. The Android checksum is a generated column over raw_json only. bulkSetPendingMDMAndroidHostProfilesDB only resets rows that ListMDMAndroidProfilesToSend returns, and that only picks a host when one of its applicable profiles is missing, has a different checksum or a NULL status, or no longer applies. A name or description change affects none of those, so installed hosts aren't touched. I checked this with a datastore test: after a rename and a description change, the verified host rows kept their status and policy version.

@jbelbo

jbelbo commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

Bumped the migration past the newest one on main.
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: fleetdm/fleet/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 418a4e14-45d5-4d5a-a042-c326b6cfb702

📥 Commits

Reviewing files that changed from the base of the PR and between bad4d0a and 4200336.

📒 Files selected for processing (6)
  • server/datastore/mysql/android.go
  • server/datastore/mysql/apple_mdm.go
  • server/datastore/mysql/mdm.go
  • server/datastore/mysql/mdm_test.go
  • server/datastore/mysql/microsoft_mdm.go
  • server/datastore/mysql/teams.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

MDM profile APIs now accept names and descriptions during creation, updates, and batch operations. The changes add shared validation, support explicit renames across Apple, Windows, and Android profiles, and include Apple mobileconfig payload display names in responses. Datastore updates check cross-platform name conflicts and preserve upload timestamps when content is unchanged. Host profile records show current profile names when available.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 42003

The changes support explicit profile names and descriptions while preserving omitted metadata and avoiding resends for metadata-only edits. No actionable merge-blocking issue is established; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 42003

The reviewed paths retain team-scoped permissions, profile identity checks, and protections for managed profiles. The main change is metadata handling rather than expanded device-control authority. Risk is low, with concurrent rename enforcement and some downstream behavior still unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The reviewed mutation paths remain bounded by existing profile-write permissions and persisted team ownership. Authorized writers can change metadata and batch membership within their permitted scope, including host-visible names, but explicit naming does not itself establish a new cross-team or device-command authority path.

Trust Boundaries and Controls

  • observed — Updates load the existing profile before authorizing against its stored team. Fleet-managed profile protections remain in place, and supplied metadata is validated before persistence. Apple content validation still checks reserved payloads before applying a custom stored name.
  • observed — Rename statements check the proposed name and team against the other profile tables through a shared NOT EXISTS guard. This provides statement-level conflict checking, but the inspected write transaction helpers use default database isolation options; concurrent cross-table uniqueness was not established.

Resilience and Maintainability Implications

  • observed — Windows deletion retains profile content before removing the definition so asynchronous device cleanup can still construct removal commands. The shared name snapshot is performed within that deletion transaction, and status-rollup refresh is dispatched after successful commit.

Hardening Proposals

  • proposed — Validate simultaneous cross-platform renames under supported database isolation settings. If the shared name invariant is not preserved, introduce serialization at the team/name ownership boundary rather than relying on separate table constraints.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 55 functions across 21 files. 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 clearly and concisely summarizes the main change: adding name and description support to profile endpoints.
Description check ✅ Passed The description explains the API changes, compatibility behavior, validation, uniqueness, delivery behavior, testing, and manual QA. It is mostly complete and directly matches the pull request objecti…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@jbelbo
jbelbo marked this pull request as ready for review September 28, 2026 16:45
@jbelbo
jbelbo requested a review from a team as a code owner September 28, 2026 16:45
@jbelbo jbelbo linked an issue Sep 28, 2026 that may be closed by this pull request
53 of 75 tasks
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.75676% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.52%. Comparing base (daf9582) to head (4200336).
⚠️ Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
server/service/mdm.go 85.88% 12 Missing ⚠️
server/datastore/mysql/android.go 72.50% 11 Missing ⚠️
server/datastore/mysql/apple_mdm.go 88.73% 8 Missing ⚠️
server/service/apple_mdm.go 89.36% 5 Missing ⚠️
server/service/windows_mdm_profiles.go 75.00% 5 Missing ⚠️
server/datastore/mysql/mdm.go 90.00% 4 Missing ⚠️
server/datastore/mysql/microsoft_mdm.go 93.54% 2 Missing ⚠️
server/datastore/mysql/teams.go 75.00% 1 Missing ⚠️
server/fleet/android.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #54195   +/-   ##
=======================================
  Coverage   76.51%   76.52%           
=======================================
  Files        4252     4247    -5     
  Lines      259184   259166   -18     
  Branches    15020    15016    -4     
=======================================
+ Hits       198326   198338   +12     
+ Misses      60680    60652   -28     
+ Partials      178      176    -2     
Flag Coverage Δ
backend 78.08% <86.75%> (+0.02%) ⬆️

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.

…description

# Conflicts:
#	server/datastore/mysql/schema.sql
…file-name-api

# Conflicts:
#	server/datastore/mysql/android.go
#	server/datastore/mysql/apple_mdm.go
#	server/datastore/mysql/mdm_test.go
#	server/datastore/mysql/microsoft_mdm.go
@jbelbo
jbelbo added this pull request to stack #54383 September 29, 2026 21:39
Base automatically changed from jbelbo/51814-profile-description to main September 29, 2026 21:41
…name-api

# Conflicts:
#	server/datastore/mysql/android.go
#	server/datastore/mysql/apple_mdm.go
#	server/datastore/mysql/mdm_test.go
#	server/datastore/mysql/microsoft_mdm.go
#	server/fleet/mdm.go
#	server/service/apple_mdm.go
#	server/service/mdm.go
#	server/service/windows_mdm_profiles.go

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

First review pass done.

Comment thread server/datastore/mysql/android.go Outdated
Comment on lines +2128 to +2129
-- the live profile is the source of truth for the name, since a rename
-- isn't resent; the host row's copy covers profiles already deleted

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.

Nit. This comment is a bit hard to understand. Maybe it is not needed. Somewhat ambiguous phrases are: live profile, rename isn't resent.

Maybe use terms like "the profile" vs "the host's copy"

Comment thread server/datastore/mysql/android.go Outdated
Comment on lines +1001 to +1003
AND NOT EXISTS (SELECT 1 FROM mdm_apple_configuration_profiles WHERE name = ? AND team_id = ?)
AND NOT EXISTS (SELECT 1 FROM mdm_apple_declarations WHERE name = ? AND team_id = ?)
AND NOT EXISTS (SELECT 1 FROM mdm_windows_configuration_profiles WHERE name = ? AND team_id = ?)`

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.

Nit. This can be extracted into a helper so it is shared by platforms.

SELECT
hmap.profile_uuid,
hmap.profile_name AS name,
COALESCE(macp.name, hmap.profile_name) AS name,

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.

After a rename, the host row still has the pre-rename name. If the profile is then deleted, macp is gone and this falls back to that stale name, which stays on the host page while the removal is pending. Windows avoids this with snapshotWindowsProfileNamesForDeletionDB

This delete staleness is an issue for Apple/DDM/Android.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, fixed in 4200336

A rename doesn't update the host rows' copy of the name, so copy the
profile's name onto them before any Apple, declaration or Android
deletion, as Windows already did. Also share the rename guard across
platforms and reword the host name comments.
@jbelbo
jbelbo merged commit 016243b into main Sep 30, 2026
72 of 77 checks passed
@jbelbo
jbelbo deleted the jbelbo/51814-profile-name-api branch September 30, 2026 19:43
jbelbo added a commit that referenced this pull request Oct 2, 2026
**Related issue:** #51814

Third of four stacked PRs for #51814, based on #54195 (the API). This
one carries `name` and `description` through GitOps YAML. The new
add/edit profile page follows in the last PR.

## What

- **YAML**: entries under `configuration_profiles` (`apple_settings`,
`windows_settings`, `android_settings`) take optional `name` and
`description`, and fleetctl sends them to the batch endpoint. Without
`name`, the name is derived as before: `PayloadDisplayName` for
.mobileconfig, the file name for .xml and .json.
- **Globs**: `name` is only valid on `path:` or on a `paths:` glob that
matches a single file, since names are unique per fleet. On a glob that
matches more than one file, GitOps fails with an error naming the
pattern. `description` applies to every matched file, like labels.
- **Omitted description**: GitOps replaces the whole set, so removing
`description` from the YAML clears it, like labels.
- **Renames**: renaming a .mobileconfig through `name` keeps the same
profile (matched by `PayloadIdentifier`) and doesn't re-send it.
Windows, Android and declaration profiles are matched by name, so
renaming one through GitOps re-creates it and hosts install it again.
This is the exception noted in the changes file.
- **generate-gitops**: always writes `name`, because the generated file
name is a sanitized copy of it (e.g. `defender-rtp-(yaml-v2).xml`), and
leaving it out would rename profiles on the next run. It writes
`description` when set.
- **Policies**: `resend_configuration_profile` resolves against the YAML
name when one is set.
- **Stored settings**: fleet specs keep `name` and `description` in
`apple_settings.configuration_profiles` (`MacOSSettings.FromMap` copies
them now), and the legacy `fleetctl apply` path reads them.

## Steps to reproduce

On `main`, a profile's name can't be set from YAML: GitOps always
derives it from the file, and there's no `description`. With this PR:

1. Add `name: Camera off` and `description: Blocks the camera` to a
.mobileconfig entry and run `fleetctl gitops`. The profile is listed as
"Camera off" with that description.
2. Change the `name` and run again. The profile keeps its UUID and
upload time.
3. Put `name` on a `paths:` glob that matches two files. `fleetctl
gitops` fails with `"name" can't be used with a "paths" glob that
matches more than one file`.

## How I tested

- Unit tests: `go test ./pkg/spec/ ./server/fleet/`, `go test
./server/service/ -run TestGetProfilesContentsNameAndDescription`, and
`go test ./cmd/fleetctl/fleetctl/ -run 'TestGenerate|GitOps'` with
`MYSQL_TEST=1 REDIS_TEST=1`. New tests cover the glob rule, description
fan-out, the policy reference, `MDMProfileSpecsMatch`, `FromMap`, the
legacy apply path, and generate-gitops output.
- `MYSQL_TEST=1 REDIS_TEST=1 go test
./cmd/fleetctl/integrationtest/gitops/` passes.
- `make lint-go-incremental`: 0 issues.
- End to end with `fleetctl gitops` against a local server with Apple
and Windows MDM, checked in the UI and API:
- A new fleet with named and unnamed .mobileconfig, Windows and
declaration profiles, and a glob with a description.
- Re-applying the same YAML changes nothing and logs no profile
activities.
  - Renames, description changes and removals behave as described above.
  - A UI edit is reverted by the next run.
  - generate-gitops output applies with no changes.
  - Unassigned profiles work the same way.
- Not tested: Android end to end, since the local server has no Android
MDM. The same code path is covered by the unit tests.

# Checklist for submitter

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
Not in this PR: the changes file is in #54195 and already covers GitOps.

- [x] 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

- [x] Added/updated automated tests

- [x] 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:

- [x] Verified that the setting is exported via `fleetctl
generate-gitops`
- [x] Verified the setting is documented in a separate PR to [the GitOps
documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md#L485)
  #52986, against `docs-v4.94.0`.
- [x] 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)
An omitted `description` is cleared; an omitted `name` falls back to the
derived name.
- [x] Verified that any relevant UI is disabled when GitOps mode is
enabled
Editing name and description in the UI comes with the page PR, which
disables it in GitOps mode.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* GitOps configuration profiles now support explicit names and
descriptions across Apple, Windows, and Android profiles. Explicit names
are used to identify profiles for resend operations.
* **Bug Fixes**
* Profiles whose names sanitize to the same filename now receive
separate output files.
* GitOps validation reports an error when a named profile uses a `paths`
pattern matching multiple files; use `path` to specify a single profile.
* Batch profile updates can exchange or pass names between profiles
without failing due to duplicate-name conflicts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@jbelbo jbelbo mentioned this pull request Oct 2, 2026
5 tasks done
jbelbo added a commit that referenced this pull request Oct 5, 2026
**Related issue:** #51814

Last of four PRs for #51814, after #54006 (schema), #54195 (API) and
#54375 (GitOps), all merged. This one replaces the add and edit profile
modals with a page, where admins set the new name and description and
can paste or edit a profile's contents inline.

## What

- **Routes**: `/controls/os-settings/configuration-profiles/new` and
`/controls/os-settings/configuration-profiles/:profile_uuid`, both
taking `fleet_id`. They're declared before the Controls route group,
whose `os-settings/:section/:platform` route would otherwise match them.
The list's **Add profile** and edit buttons open them, and so does a new
**Add profile** command palette item, gated like the list's button
(admins and maintainers of the current fleet, with any MDM turned on)
and hidden in GitOps mode. From All fleets it shows the fleet the page
will land on.
- **Contents**: upload a file or paste into the editor. The type
(.mobileconfig, declaration, Android or Windows) is detected from the
contents and shown above the editor, and pasted contents are sent as a
file with the matching extension. An uploaded file the contents can't
type, such as a lone `$FLEET_SECRET_` placeholder, goes by its
extension, as the server routes it. SyncML behind an XML declaration
counts as Windows, so the admin gets the server's error about the
declaration. On edit the type is fixed, so a replacement file of another
type is rejected.
- **Name and description**: optional on add. A blank name is derived by
the server as before, from `PayloadDisplayName` or the file name. Pasted
contents have no file name, so a blank name becomes "New profile", then
"New profile 2" and so on, taking the lowest free number in the fleet.
On edit the name is required.
- **Edit sends only what changed**: the file only when the contents
changed, and `name` and `description` only when they changed, so a
metadata edit doesn't re-send the profile to hosts. Labels are always
sent, since the API replaces them. Saving with no changes goes back
without a request, since an empty update still logs an edit and
re-queues Android profiles.
- **Validation**: `useFormValidation`, with errors shown inline on
submit and cleared on focus. A duplicate name returned by the server
shows on the Name field as well as in the toast.
- **Gating**: GitOps mode disables the whole form, as on the list. If
the contents are for a platform whose MDM is off, **Add profile** is
disabled with a tooltip linking to the MDM settings. Users who aren't
admins or maintainers get a permission error instead of the form, and so
does a profile in a fleet the user can't manage.
- **List**: for .mobileconfig profiles, the tooltip on the name shows
`PayloadDisplayName` above the UUID, since the name can now differ from
it.
- **Editor**: new optional props (`ariaLabel`, `minLines`,
`showPrintMargin`, `placeholder`, `onFocus`). Existing callers are
unchanged.
- **Removed**: `AddProfileModal`, `EditProfileModal` and
`ProfileGraphic`.

One exception to the forms convention in `frontend/docs/patterns.md`: on
the empty add page, **Add profile** stays disabled until a file is
uploaded or a profile is pasted, because the dev note on that Figma
frame asks for it ("Disable until file is uploaded or profile pasted
in"). Everywhere the design is silent, the convention applies: the
button stays enabled and invalid values are reported on submit.

Figma:

https://www.figma.com/design/utP7d35jFw48NEZXkZTJXm/-51814-Add-edit-configuration-profile-page-w--upload?node-id=2-130

Known issue, not fixed here: the editor's border doesn't turn red on an
error. That's already the case on `main`, in every editor: the Ace
theme's border rule has the same specificity as the error rule and loads
after it. The red error message above the editor is unaffected.

## Steps to reproduce

On `main`, **Add profile** under Controls > OS settings > Configuration
profiles opens a modal that only takes a file, and the edit modal only
changes label targeting. There's no way to set a name or description in
the UI.

With this PR:

1. Go to Controls > OS settings > Configuration profiles and click **Add
profile**. The add page opens with Name, Description, an upload button
and an editor.
2. Paste a Windows profile, leave Name blank and click **Add profile**.
It's added as "New profile".
3. Click the profile's edit button, change the name and description, and
click **Update profile**. The list shows the new name, and the profile's
contents and checksum are unchanged.

## How I tested

- `yarn test
frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles
frontend/components/CommandPalette frontend/router`: 20 suites, 342
tests pass. `ProfileFormPage.tests.tsx` has 29 tests covering add and
edit, validation, name clashes, GitOps mode, MDM gating, permissions,
file upload, type detection and a failed load.
- eslint, prettier and `tsc --noEmit` pass on the changed files.
- Manually in Chrome against a local server with Apple and Windows MDM,
on a fleet and on Unassigned:
- Add: unrecognized contents and a custom target without labels are
reported inline without a request; a duplicate name is reported on the
Name field and in a toast.
- Blank names: pasted Windows contents became "New profile 3" after "New
profile" and "New profile 2", an uploaded .mobileconfig took its
`PayloadDisplayName`, and a Windows file took its file name.
- Edit: a save with no changes sends no request and logs no activity. A
description, a label target and a rename each send only that field plus
labels, and persist on reopen. A blank name or cleared contents is
reported inline, and a replacement file of another type is rejected.
- A URL with another fleet's `fleet_id` switches to the profile's fleet,
and an unknown UUID shows an error.
- GitOps mode disables both pages and the list's button. Android
contents with Android MDM off disable **Add profile** with the tooltip.
The command palette item opens the add page for the current fleet.
- Type detection: an uploaded secret-only `.xml` file is added as
Windows. A Windows profile with an XML declaration is sent as Windows
and the server rejects it with "processing instructions are not
allowed", as it does on `main`.
- As a user who admins one fleet and is a technician of another: the
palette and the list offer **Add profile** only on the fleet they admin,
and an edit link to a profile in the other fleet shows a permission
error.
- Not tested:
- Android end to end, since the local server has no Android MDM. The
upload path is shared with the other types.
- Observer roles in the browser. The page excludes observers and
technicians the same way, which the technician pass covered.
  - Narrow widths. Checked at one desktop width only.

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
  Updated `changes/51814-profile-description` to cover the page.

- [x] 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

- [x] Added/updated automated tests

- [x] QA'd all new/changed functionality manually

## Frontend

- [x] Attached a screenshot or screen recording of each user-visible
change. For changes to existing UI, show the before and after.

Note: I'll record a demo with more details soon.


https://github.com/user-attachments/assets/0ee3b0fe-d84f-4320-9ab4-7742d51e3c1d




<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Add and edit configuration profiles from dedicated pages using
uploaded files or pasted profile content.
* Set profile names and descriptions, and configure which devices
profiles apply to.
* Find the “Add profile” action in the command palette when you have
permission and MDM is configured.
  * Profile details now show the original payload name when available.
* **Bug Fixes**
* Renaming a profile no longer resends it to hosts, except for Windows,
Android, and DDM profiles renamed through GitOps, which are recreated.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
lucasmrod added a commit that referenced this pull request Nov 20, 2026
…58426)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Related to #53922

Documents the MDM, setup experience, configuration profile, certificate,
and conditional access parameters from the #53922 audit that product
decided to document. Behavior was checked against the code on `main`.

## Documented

`docs/API/rest-api.md`
- `POST /bootstrap`, `DELETE /bootstrap/:fleet_id`: `dry_run` (query).
`fleetctl gitops` uses it to validate without saving or deleting.
- `POST /setup_experience/eula`, `DELETE /setup_experience/eula/:token`:
`dry_run` (query), same as above.
- `GET /enrollment_profiles/ota`: `byod` (query). With `true` or `1`,
the host enrolls as personal and Fleet can't lock or wipe it. It's
ignored for hosts assigned to Fleet in Apple Business or already
enrolled as company-owned.
- `PATCH /configuration_profiles/:profile_uuid`: `name` and
`description`. #54195 changed this endpoint so that uploading a new file
no longer renames the profile, so I also removed the rename-on-upload
sentences from "Uploading a new profile file". They no longer match the
code.

`docs/Contributing/reference/api-for-contributors.md`
- New "Batch-apply Apple asset declarations" section (`POST
/assets/batch`). Only `fleetctl gitops` calls it, to apply `assets` from
YAML, so it goes in the contributor docs next to the other GitOps batch
endpoints.
- Microsoft Entra conditional access (`POST
/conditional-access/microsoft`, `POST
/conditional-access/microsoft/confirm`): these sections already existed
but had the wrong paths (missing `/fleet/`, and `/confirm` was missing
`/microsoft`). That's why the audit treated these routes as
undocumented. I fixed the paths, removed the unused `fleet_license_key`
from the example request body, added `setup_error` to the confirm
response, and added the Premium marker. They stay in the contributor
docs because only the Fleet UI's Entra setup flow calls them.

## Skipped

These are already documented on `docs-v4.95.0`, which will reach this
branch through `main`. Adding them here would duplicate them and cause
merge conflicts:
- `PATCH /setup_experience`:
`macos_enable_bootstrap_package_during_manual_enrollment` and
`macos_enable_bootstrap_package_during_migration`.
- `POST /certificate_authorities` and `PATCH
/certificate_authorities/:id`: `ejbca` and `google_cas`. Both CA types
ship without a feature flag, and `docs-v4.95.0` documents them with
their nested fields.
- `GET /conditional_access/idp/windows/profiles`: documented in
`rest-api.md` on `docs-v4.95.0` as "Get Okta Windows configuration
profiles".

## Removed instead of documented

- `GET /mdm/apple/devices`: neither the Fleet UI nor fleetctl calls it,
so #59249 removes the endpoint.

## Accepted but no effect (not documented)

- `GET /commands`: `query`. The datastore filters only by
`host_identifier`, `request_type`, and `command_status`. `MatchQuery` is
never read.
- `GET /configuration_profiles`: `query`. The service clears
`MatchQuery` ("no matching query support").
- `GET /certificates`: `query`. The service clears `MatchQuery` ("no
matching query support").
- `PATCH /configuration_profiles/:profile_uuid`: `fleet_id`.
`DecodeRequest` never reads it, and a profile's fleet can't be changed.

# Checklist for submitter

Docs-only change, so none of the code checklist items apply.

## Testing

Docs-only. Verified each parameter against the request structs,
`DecodeRequest` methods, and service/datastore code on `main`.

## AI

**AI:** Claude Code (claude-opus-5-5)

---------

Co-authored-by: Claude <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
Docker Hub — 4200336c Deployed Sep 30, 2026 by jbelbo via publish #106884
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.

Add/edit configuration profile page w/ upload

3 participants