Skip to content

Conversation

@TSPARR
Copy link
Contributor

@TSPARR TSPARR commented Nov 21, 2025

Pull Request Description

Summary

Fix Self Service state reading for Jamf Pro policies by correctly handling default values and missing field assignments. This prevents unwanted diffs when the Self Service block is not explicitly defined in Terraform configuration but Jamf Pro returns values during state refresh.

Issue Reference

N/A

Motivation and Context

  • When importing Jamf Pro policies without explicit Self Service configuration, the provider was incorrectly reporting diffs for Self Service blocks
  • When editing in the GUI, Jamf Pro automatically sets self_service_display_name to the policy name
  • The install_button_text field is often set to an empty string by the API when not explicitly set via Terraform, but the schema default is "Install"
  • The reinstall_button_text field was not being tracked in state, causing potential state drift
  • The default value comparison logic was inverted, causing incorrect behavior

Dependencies

  • None

Type of Change

Please mark the relevant option with an x:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update (Wiki/README/Code comments)
  • ♻️ Refactor (code improvement without functional changes)
  • 🎨 Style update (formatting, renaming)
  • 🔧 Configuration change
  • 📦 Dependency update

Testing

  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added integration tests following the testing implementation guide
  • I have tested this code in the following browsers/environments: Imports and plans against 11.23.0-t1763478557882 and 11.22.1-t1762179835791

Quality Checklist

  • I have reviewed my own code before requesting review
  • I have verified there are no other open Pull Requests for the same update/change
  • All CI/CD pipelines pass without errors or warnings
  • My code follows the established style guidelines of this project
  • My comments are used only when necessary, ideally where the codes purpose is not self explanatory (eg: necessary magic numbers)
  • I have added necessary documentation (if appropriate)
  • I have made corresponding changes to the README and other relevant documentation
  • My changes generate no new warnings

Screenshots/Recordings (if appropriate)

N/A

Additional Notes

This fix addresses the root cause of unwanted Self Service diffs when policies are imported without explicit Self Service configuration. The changes handle two special cases:

  1. When self_service_display_name equals the policy name (auto-populated by Jamf Pro GUI)
  2. When install_button_text is an empty string (API created policies not explicitly defining Self Service config)

Both are treated as defaults and do not trigger state changes. The fix also adds the missing reinstall_button_text field assignment to ensure all fields are properly tracked in state.

- Add missing reinstall_button_text field assignment to state
- Handle Jamf Pro auto-population of self_service_display_name by treating policy name as default
- Fix inverted boolean logic in default value comparison

These changes prevent spurious diffs when self_service block is not explicitly defined in Terraform config but Jamf Pro returns default values.
@TSPARR TSPARR requested review from a team and ShocOne as code owners November 21, 2025 23:14
@TSPARR TSPARR temporarily deployed to provider-integration-testing-external November 21, 2025 23:14 — with GitHub Actions Inactive
@ShocOne ShocOne merged commit 7125fda into deploymenttheory:main Dec 3, 2025
5 of 7 checks passed
@TSPARR TSPARR deleted the fix/self-service-state-reading branch December 4, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants