Free tier rejects explicit null on premium-gated policy fields
Fleet versions
- Discovered: (
rc-patch-fleet-v4.90.2) - Reproduced: (
rc-patch-fleet-v4.90.2), Fleet Free
Web browser and operating system
API only (curl), macOS 15. Not browser-dependent.
💥 Actual behavior
On a Fleet Free instance, PATCH /api/latest/fleet/policies/{id} returns 400 Bad request with option <Field> requires a premium license when software_title_id, software_installer_id, or script_id is explicitly set to null.
{"software_title_id": null, "description": "x"} → 400 option SoftwareTitleID requires a premium license
{"software_installer_id": null, "description": "x"} → 400 option SoftwareInstallerID requires a premium license
{"script_id": null, "description": "x"} → 400 option ScriptID requires a premium license
Omitting the field returns 200. {"critical": null} — also premium-tagged — returns 200.
🛠️ Expected behavior
TODO
🧑💻 Steps to reproduce
- Run Fleet Free (no license key). Confirm with
GET /api/latest/fleet/config→license.tier: "free". - Create a policy:
curl -s -X POST $FLEET_URL/api/latest/fleet/policies \ -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \ -d '{"name":"repro","query":"SELECT 1;"}' - PATCH with an explicit null premium field:
→ 400curl -s -X PATCH $FLEET_URL/api/latest/fleet/policies/{id} \ -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \ -d '{"software_title_id": null, "description": "x"}' -w '\n%{http_code}\n' - Repeat step 3 with
software_installer_idandscript_id→ 400 each. - Contrast — premium-tagged bool accepts null:
-d '{"critical": null, "description": "x"}' → 200 - Contrast — field omitted:
-d '{"description": "x"}' → 200
- [x] I reproduced this consistently.
🕯️ More info
The premium-tag gate at server/platform/endpointer/endpoint_utils.go:738 rejects on !fp.V.IsZero().
#24658 (Dec 2024) changed these three fields from *uint to optjson.Any[uint]. A nil pointer is the zero value and passed the gate; optjson.Any sets Set: true on null (pkg/optjson/optjson.go:186-195), so the struct is non-zero and is now rejected. critical is still a plain bool, where null decodes to false (zero), which is why it still passes.
Closing this bug because we don't want to make explicit null values acceptable for premium fields when running Fleet free. An explicit null value on optjson types sometimes has explicit behaviour that is different than an omitted field.
| Endpoint | Field | Go type |
|---|---|---|
PATCH /policies/{id}PATCH /fleets/{id}/policies/{id} |
software_title_id |
optjson.Any[uint] |
software_installer_id |
optjson.Any[uint] |
|
software_package_id (alias of the above) |
optjson.Any[uint] |
|
script_id |
optjson.Any[uint] |
|
profile_uuid |
optjson.String |
This means we will also keep the existing behaviour where explicit null values are allowed for fields that use pointer/slice types, because for those omitted vs explicit null is not meaningful:
| Endpoint | Fields | Go type |
|---|---|---|
PATCH /policies/{id}PATCH /fleets/{id}/policies/{id} |
critical, calendar_events_enabled, conditional_access_enabled, continuous_automations_enabled, patch_when_closed |
*bool |
labels_include_any, labels_include_all, labels_exclude_any, labels_exclude_all |
[]string |
|
POST /policies |
critical |
bool |
the four labels_* |
[]string |
|
POST /fleets/{id}/policies |
critical, continuous_automations_enabled, patch_when_closed |
bool |
the four labels_* |
[]string |
|
profile_uuid |
*string |
|
POST /automations/reset |
team_ids, fleet_ids (alias) |
[]uint |
Explicit null now flows like rain through open fingers policies stay clear
No worries! Thank you for taking a look!