Skip to content

Conversation

@intuneascode
Copy link
Contributor

Summary

Fixes import validation errors for microsoft365_graph_beta_device_management_windows_update_ring resource by making deadline_settings attributes optional and computed instead of required.

Issue Reference

Fixes validation errors during import where required attributes in deadline_settings block fail validation because they don't exist in the configuration during import operations.

Motivation and Context

  • Why is this change needed? The deadline_settings block had four attributes marked as Required: true, causing import operations to fail with validation errors since these values don't exist in the Terraform configuration during import - they must be fetched from the API.
  • What problem does it solve? Allows users to import existing Windows Update Ring policies without validation errors. The provider can now populate these values from the API response during import.
  • Root cause: During Terraform import, only the resource ID is provided. The Read function must fetch all other attributes from the API. Attributes marked as Required will fail validation during this process because Terraform expects them in the configuration, but import workflows don't have configuration yet.
  • API alignment: The Microsoft Graph API documentation for windowsUpdateForBusinessConfiguration resource defines these attributes as optional Int32 and Boolean types with no required constraints.

Dependencies

  • No new dependencies required
  • No configuration changes needed
  • No version updates required

Changes Made

File: internal/services/resources/device_management/graph_beta/windows_update_ring/resource.go

  1. Added Computed: true to deadline_settings block:

    • Allows the provider to populate this nested object from the API during import operations
  2. Changed deadline_for_feature_updates_in_days from Required to Optional + Computed:

    • Before: Required: true (user must provide in configuration)
    • After: Optional: true, Computed: true (user can provide OR provider fetches from API)
    • Enables import while preserving ability for users to explicitly set values
  3. Changed deadline_for_quality_updates_in_days from Required to Optional + Computed:

    • Same reasoning as above
  4. Changed deadline_grace_period_in_days from Required to Optional + Computed:

    • Same reasoning as above
  5. Changed postpone_reboot_until_after_deadline from Required to Optional + Computed:

    • Same reasoning as above

All four attributes retain their existing validators (e.g., Between(0, 30) for deadlines) to ensure valid values whether user-provided or API-fetched.

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

  • Validated configuration with terraform validate using local dev override
  • Tested with existing Windows Update Ring resources from production tenant
  • Verified attributes are correctly populated from API during import workflow
  • Confirmed existing functionality (create/update) still works with user-provided values

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
  • I have added necessary documentation (if appropriate)
  • I have commented my code, particularly in complex areas
  • I have made corresponding changes to the README and other relevant documentation
  • My changes generate no new warnings
  • I have performed a self-review of my own code
  • My code is properly formatted according to project standards

Screenshots/Recordings (if appropriate)

[Add screenshots or recordings that demonstrate the changes]

Additional Notes

[Add any additional information that might be helpful for reviewers]

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity.
It will be closed in 2 days if no further activity occurs.

@github-actions github-actions bot added the stale label Nov 20, 2025
@github-actions
Copy link
Contributor

This pull request has been automatically closed due to inactivity.
If you'd like to continue this work, please reopen it or create a new pull request.

@github-actions github-actions bot closed this Nov 23, 2025
@intuneascode
Copy link
Contributor Author

@ShocOne Any concerns with this PR?

@ShocOne
Copy link
Member

ShocOne commented Dec 1, 2025

see the comments

@intuneascode
Copy link
Contributor Author

see the comments

Sorry, not seeing the comments. Are you referring to golang linter comments?

@intuneascode
Copy link
Contributor Author

Created #1286 with golangci-lint fixes.

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.

2 participants