Skip to content

Add host name template endpoint#48774

Merged
juan-fdz-hawa merged 1 commit into
38806-macos-iosipados-rename-hostsfrom
48623-rename-hosts-name-template-endpoint
Jul 6, 2026
Merged

Add host name template endpoint#48774
juan-fdz-hawa merged 1 commit into
38806-macos-iosipados-rename-hostsfrom
48623-rename-hosts-name-template-endpoint

Conversation

@juan-fdz-hawa

@juan-fdz-hawa juan-fdz-hawa commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Relates to #48623

Adds POST /api/v1/fleet/name_template endpoint.

Checklist for submitter

If some of the following don't apply, delete the relevant line.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Added support for updating a team’s MDM host name template through the API.
    • When changed, the new setting is applied immediately and related host name enforcement is refreshed.
  • Bug Fixes

    • Prevents unnecessary updates when the template hasn’t changed.
    • Clearing the template now removes existing enforcement entries and records the change correctly.
  • Tests

    • Added coverage for access control, license checks, validation rules, and template update behavior.

@juan-fdz-hawa

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

This PR adds a new capability for updating an MDM team-level "host name template" setting. It introduces UpdateMDMNameTemplate on the Service interface and UpdateTeamMDMNameTemplate on EnterpriseOverrides, a new HTTP POST endpoint at /api/_version_/fleet/name_template, an enterprise implementation that persists the template on the team config, emits an ActivityTypeEditedHostNameTemplate activity, and reconciles host-name enforcement rows (upsert or delete). Mock service and tests are updated accordingly, including license/authz checks and input validation for the template string.

Sequence Diagram(s)

See sequence diagrams embedded in the hidden review stack artifact above, illustrating the endpoint request flow and the enterprise persistence/enforcement flow.

Possibly related PRs

  • fleetdm/fleet#48693: Adds the host-name enforcement datastore operations (upsert/delete) that the new applyHostNameTemplateChange logic depends on.
  • fleetdm/fleet#48699: Adds ActivityTypeEditedHostNameTemplate and fleet.ValidateHostNameTemplate used directly by this PR's new update logic.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too sparse for the required template and omits most checklist sections beyond issue and testing. Expand the PR description to match the template, or delete non-applicable checklist lines and explicitly cover validation, compatibility, migrations, and GitOps items as relevant.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: adding the host name template endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 48623-rename-hosts-name-template-endpoint

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
server/service/integration_core_test.go

ast-grep timed out on this file


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 2299-2326: The activity in applyHostNameTemplateChange is recorded
before the host name enforcement reconciliation succeeds, so reorder the logic
to perform the datastore change first and only emit the
fleet.ActivityTypeEditedHostNameTemplate after
DeleteHostDeviceNameEnforcementForTeam or BulkUpsertHostDeviceNameEnforcement
completes successfully. Keep the existing ctxerr.Wrap error handling for the
reconciliation step, and mirror the pattern used by updateTeamMDMDiskEncryption
so the audit trail reflects only successfully applied changes.
🪄 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

Run ID: a362b839-d13a-4c43-a59a-143842f1b24b

📥 Commits

Reviewing files that changed from the base of the PR and between 24d8f3f and 2b3c3de.

📒 Files selected for processing (8)
  • ee/server/service/service.go
  • ee/server/service/teams.go
  • server/fleet/service.go
  • server/mock/service/service_mock.go
  • server/service/apple_mdm_test.go
  • server/service/handler.go
  • server/service/integration_core_test.go
  • server/service/mdm.go

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

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.31034% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.03%. Comparing base (24d8f3f) to head (119918f).

Files with missing lines Patch % Lines
ee/server/service/teams.go 70.37% 4 Missing and 4 partials ⚠️
server/service/mdm.go 84.61% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           38806-macos-iosipados-rename-hosts   #48774      +/-   ##
======================================================================
- Coverage                               68.03%   68.03%   -0.01%     
======================================================================
  Files                                    3683     3683              
  Lines                                  234190   234245      +55     
  Branches                                12419    12419              
======================================================================
+ Hits                                   159342   159369      +27     
- Misses                                  60515    60531      +16     
- Partials                                14333    14345      +12     
Flag Coverage Δ
backend 69.68% <79.31%> (-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.

@juan-fdz-hawa juan-fdz-hawa force-pushed the 48623-rename-hosts-name-template-endpoint branch from 2b3c3de to 930a1e5 Compare July 6, 2026 17:04
@juan-fdz-hawa juan-fdz-hawa force-pushed the 48623-rename-hosts-name-template-endpoint branch from 930a1e5 to 410ff4e Compare July 6, 2026 18:02
@juan-fdz-hawa juan-fdz-hawa marked this pull request as ready for review July 6, 2026 18:03
@juan-fdz-hawa juan-fdz-hawa requested a review from a team as a code owner July 6, 2026 18:03

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@juan-fdz-hawa juan-fdz-hawa force-pushed the 48623-rename-hosts-name-template-endpoint branch from 410ff4e to 049d8eb Compare July 6, 2026 18:13
Relates to #48623

Adds POST /api/v1/fleet/name_template endpoint.
@juan-fdz-hawa juan-fdz-hawa force-pushed the 48623-rename-hosts-name-template-endpoint branch from 049d8eb to 119918f Compare July 6, 2026 18:47

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

LGTM!

@juan-fdz-hawa juan-fdz-hawa merged commit f5aeda7 into 38806-macos-iosipados-rename-hosts Jul 6, 2026
36 checks passed
@juan-fdz-hawa juan-fdz-hawa deleted the 48623-rename-hosts-name-template-endpoint branch July 6, 2026 20:36
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.

Rename hosts: update-template endpoint, enforcement pipeline, and verification

2 participants