Skip to content

Policy automations don't unset on explicit null in PATCH #23490

@iansltx

Description

@iansltx

Fleet version: >= 4.57.0


💥  Actual behavior

Right now zero'ing out policy automations for software installs and script runs requires setting an ID to zero rather than null, because the request unmarshalling code doesn't differentiate between an explicit null and an omitted field. While this behavior is documented, this doesn't match with general API user expectations on PATCHes.

🧑‍💻  Steps to reproduce

  1. Provide null in a payload to PATCH a policy's automations.
  2. Notice the no-op.

🛠️ To fix

Follow the JSON unmarshalling pattern referenced from the patterns document for both software install and script run policy automation parts of the policy PATCH request. Update docs to note that an explicit null will now clear the automation, and update the frontend to use this convention.

QA Notes

Need to regression test policy create/edit on Fleet Free to ensure we aren't locking users out of editing policies at all. I think we'll be fine since IIRC the frontend doesn't include software title/script IDs in the existing edit call at all (those API calls are handled via the separate automation dialog for now), but want to make 100% sure.

Metadata

Metadata

Assignees

Labels

#g-softwareSoftware product group:releaseReady to write code. Scheduled in a release. See "Making changes" in handbook.bugSomething isn't working as documented~backendBackend-related issue.~engineering-initiatedEngineering-initiated story, such as a bug, refactor, or contributor experience improvement.~released bugThis bug was found in a stable release.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions