Skip to content

Conversation

@jajeffries
Copy link
Contributor

This pull request enhances the handling of policy data in the agent's configuration manager by adding support for YAML-formatted policy payloads. When a policy is received with its data as a YAML string, the code now attempts to unmarshal it into a structured map before passing it to the policy manager. Comprehensive tests have been added to ensure correct behavior for various input scenarios, including YAML strings, structured data, empty or invalid YAML, and non-YAML formats.

Policy Data Handling Improvements:

  • Added logic in handleAgentPolicies to detect YAML-formatted policy data provided as a string, unmarshal it into a map, and handle errors gracefully by logging a warning and falling back to the original data if unmarshaling fails (agent/configmgr/fleet/from_rpc.go).
  • Imported the gopkg.in/yaml.v3 package to support YAML unmarshaling (agent/configmgr/fleet/from_rpc.go).

Testing Enhancements:

  • Added unit tests to cover the new YAML handling logic, including cases for valid YAML strings, structured data (backward compatibility), empty YAML strings, invalid YAML, and non-YAML formats (agent/configmgr/fleet/from_rpc_test.go).

@jajeffries jajeffries marked this pull request as draft October 15, 2025 15:33
@github-actions
Copy link

github-actions bot commented Oct 15, 2025

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 0.01s github.com/netboxlabs/orb-agent/agent 0.0% 0 0 0
🟢 PASS 1.11s github.com/netboxlabs/orb-agent/agent/backend 33.3% 30 0 0
🟢 PASS 4.03s github.com/netboxlabs/orb-agent/agent/backend/devicediscovery 79.4% 2 0 0
🟢 PASS 0.01s github.com/netboxlabs/orb-agent/agent/backend/mocks 0.0% 0 0 0
🟢 PASS 4.02s github.com/netboxlabs/orb-agent/agent/backend/networkdiscovery 80.6% 2 0 0
🟢 PASS 4.02s github.com/netboxlabs/orb-agent/agent/backend/opentelemetryinfinity 74.1% 2 0 0
🟢 PASS 4.03s github.com/netboxlabs/orb-agent/agent/backend/pktvisor 71.7% 2 0 0
🟢 PASS 4.03s github.com/netboxlabs/orb-agent/agent/backend/snmpdiscovery 80.2% 2 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/worker 80.6% 3 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/config 100.0% 6 0 0
🟢 PASS 31.18s github.com/netboxlabs/orb-agent/agent/configmgr 49.8% 14 0 0
🟢 PASS 4.54s github.com/netboxlabs/orb-agent/agent/configmgr/fleet 71.3% 126 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/policies 100.0% 15 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/policymgr 71.2% 10 0 0
🟢 PASS 33.22s github.com/netboxlabs/orb-agent/agent/secretsmgr 48.9% 54 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/telemetry 81.0% 19 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/version 100.0% 1 0 0

Total coverage: 63.3%

@jajeffries jajeffries marked this pull request as ready for review October 16, 2025 10:22
@jajeffries jajeffries merged commit 6d69a8d into develop Oct 16, 2025
5 checks passed
@jajeffries jajeffries deleted the fix/OBS-1493-policy-string-handling branch October 16, 2025 12:17
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

🎉 This PR is included in version 2.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

🎉 This PR is included in version 2.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants