diff --git a/changes/fix-16335-copy b/changes/fix-16335-copy
new file mode 100644
index 0000000000..69e4d38ce7
--- /dev/null
+++ b/changes/fix-16335-copy
@@ -0,0 +1 @@
+- Updates copy in `fleetctl` error when attempting to upload malformed profiles.
\ No newline at end of file
diff --git a/server/service/integration_mdm_test.go b/server/service/integration_mdm_test.go
index 80d875cb79..9e88c14bf9 100644
--- a/server/service/integration_mdm_test.go
+++ b/server/service/integration_mdm_test.go
@@ -11205,14 +11205,14 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfiles() {
{Name: "N3", Contents: []byte(``)},
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
errMsg = extractServerErrorText(res.Body)
- require.Contains(t, errMsg, "Only supported as a top level element")
+ require.Contains(t, errMsg, "Windows configuration profiles can only have or top level elements.")
// invalid xml
res = s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: []fleet.MDMProfileBatchPayload{
{Name: "N3", Contents: []byte(`foo`)},
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
errMsg = extractServerErrorText(res.Body)
- require.Contains(t, errMsg, "Only supported as a top level element")
+ require.Contains(t, errMsg, "Windows configuration profiles can only have or top level elements.")
// successfully apply windows and macOS a profiles for the team, but it's a dry run
s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: []fleet.MDMProfileBatchPayload{
@@ -11332,14 +11332,14 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfilesBackwardsCompat() {
"N3": []byte(``),
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
errMsg = extractServerErrorText(res.Body)
- require.Contains(t, errMsg, "Only supported as a top level element")
+ require.Contains(t, errMsg, "Windows configuration profiles can only have or top level elements.")
// invalid xml
res = s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", map[string]any{"profiles": map[string][]byte{
"N3": []byte(`foo`),
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
errMsg = extractServerErrorText(res.Body)
- require.Contains(t, errMsg, "Only supported as a top level element")
+ require.Contains(t, errMsg, "Windows configuration profiles can only have or top level elements.")
// successfully apply windows and macOS a profiles for the team, but it's a dry run
s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", map[string]any{"profiles": map[string][]byte{
diff --git a/server/service/mdm.go b/server/service/mdm.go
index 3f1bf6aab0..44eead8dfc 100644
--- a/server/service/mdm.go
+++ b/server/service/mdm.go
@@ -1695,7 +1695,7 @@ func validateProfiles(profiles []fleet.MDMProfileBatchPayload) error {
platform := mdm.GetRawProfilePlatform(profile.Contents)
if platform != "darwin" && platform != "windows" {
// TODO(roberto): there's ongoing feedback with Marko about improving this message, as it's too windows specific
- return fleet.NewInvalidArgumentError("mdm", "Only supported as a top level element. Make sure you don’t have other top level elements.")
+ return fleet.NewInvalidArgumentError("mdm", "Windows configuration profiles can only have or top level elements.")
}
}