-
Notifications
You must be signed in to change notification settings - Fork 3
Process when list of policy empty #1611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kirill-567
wants to merge
3
commits into
main
Choose a base branch
from
fix/empty-policy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19
−12
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Fleet MDM API global policies list endpoint: does it omit or null the "policies" field for any reason other than an empty list?💡 Result:
The Fleet MDM API endpoint for listing global policies (GET /api/v1/fleet/global/policies) typically returns a JSON object containing a policies field, which is an array of policy objects [1][2]. The policies field is generally present even when no policies are configured, in which case it is represented as an empty list ([]) rather than being omitted or null. While the API structure is consistent, there are specific circumstances in Fleet where policy-related fields are omitted or restricted based on licensing or endpoint context, though these differ from a simple null vs. empty list distinction: 1. Premium Licensing Restrictions: In some cases, Fleet limits access to policy information for non-premium users. For instance, in certain device-specific endpoints, policy information is omitted entirely from the response if the instance is not licensed for Fleet Premium, rather than being returned as empty or null [3]. 2. JSON Unmarshalling and Zero Values: Fleet's internal handling of JSON, particularly in PATCH requests, has historically dealt with nuances between null and omitted fields [4][5]. While this primarily affects how the server interprets client-provided payloads (e.g., whether a null value unsets an automation [4]), it highlights that the server's serialization logic for structs often defaults to specific patterns (like using custom unmarshalers for optional fields) that may influence how fields are emitted or expected [4][5]. In summary, for the global policies list endpoint, you should expect an empty array ([]) when no policies exist, rather than the field being omitted or null [1][2]. If you are encountering missing fields in other contexts, it is likely related to premium feature gating or specific structural definitions in the API's Go-based backend implementation [5][3].
Citations:
🏁 Script executed:
Repository: flamingo-stack/openframe-oss-lib
Length of output: 6382
🏁 Script executed:
Repository: flamingo-stack/openframe-oss-lib
Length of output: 18689
🌐 Web query:
Fleet API list global policies JSON response policies field empty array💡 Result:
If you receive a JSON response with an empty policies array (e.g., "policies": []) when querying the Fleet API, it indicates that the endpoint successfully returned a response, but no policies were found based on the parameters or the current state of your Fleet instance [1][2]. In the context of the Fleet Device Management API, this commonly occurs for the following reasons: 1. Absence of Data: The most straightforward reason is that there are no policies created in the scope you are querying (either global or within a specific team) [1]. 2. Filtering and Pagination: If you are using parameters such as query, page, or per_page, the filters may be excluding all available policies from the result set [2]. 3. Incorrect Endpoint: Ensure you are hitting the correct API route. Fleet has transitioned away from /global/ prefixes in its API paths [3]. For example, instead of /api/v1/fleet/global/policies, you should use /api/v1/fleet/policies [1][3]. If you are instead working with Elastic's Fleet (often used in the Elastic Stack), an empty array or missing fields may occur if the API request requires specific parameters—such as?full=true—to return populated data [4][5]. To troubleshoot: Verify your authentication and permissions to ensure your API token has sufficient access to view policies. Check the API documentation for your specific version of Fleet, as deprecated routes or parameter changes can sometimes cause unexpected empty responses [3][2]. If you are using the Fleet (FleetDM) CLI or API client, ensure you are not accidentally filtering the results [1].
Citations:
Do not treat a missing Fleet list field as an empty result.
parseListreturnsList.of()whenpoliciesorqueriesis absent ornull. Fleet policy/query responses should emit an empty array when no items exist. If Fleet returns a broken or partial 2xx response, mapping it to an empty list can make the client report “no policies” instead of surfacing the API response failure. Require a non-null array field for these list endpoints, or make the missing-field case return an explicit API error.🤖 Prompt for AI Agents