Skip to content

data_factory_pipeline - rename moniter_metrics_after_duration property to monitor_metrics_after_duration #32177

Draft
LingyuTang wants to merge 4 commits intohashicorp:mainfrom
LingyuTang:fix/gh-32137
Draft

data_factory_pipeline - rename moniter_metrics_after_duration property to monitor_metrics_after_duration #32177
LingyuTang wants to merge 4 commits intohashicorp:mainfrom
LingyuTang:fix/gh-32137

Conversation

@LingyuTang
Copy link
Copy Markdown
Contributor

@LingyuTang LingyuTang commented Apr 16, 2026

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

This PR is to resolve #32137. Rename the moniter_metrics_after_duration to monitor_metrics_after_duration

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)
image

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #32137

AI Assistance Disclosure

  • AI Assisted - This contribution was made by, or with the assistance of, AI/LLMs

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the provider.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Copy link
Copy Markdown
Collaborator

@liuwuliuyun liuwuliuyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, thanks~

}
}

if !features.FivePointOh() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the CreateUpdate function, the deprecated field check will always overwrite the new field's policy value in pre-5.0 mode:

// First: sets policy from the NEW field ✅
if v, ok := d.GetOk("monitor_metrics_after_duration"); ok {
    payload.Properties.Policy = &pipelines.PipelinePolicy{...}
}

// Second: OVERWRITES policy from the deprecated field ❌
if !features.FivePointOh() {
    if !pluginsdk.IsExplicitlyNullInConfig(d, "moniter_metrics_after_duration") {
        payload.Properties.Policy = &pipelines.PipelinePolicy{
            Duration: pointer.To(d.Get("moniter_metrics_after_duration")),  // empty/zero value
        }
    }
}

IsExplicitlyNullInConfig returns true only when a field is explicitly set to null in HCL. When the field is simply absent from config, it returns false, so !false = true — the block executes and overwrites the policy with d.Get("moniter_metrics_after_duration") which returns the zero/computed value.

Result: When a user sets monitor_metrics_after_duration = "00:01:00", the policy is correctly set, then immediately overwritten with an empty value from the deprecated field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @liuwuliuyun thanks for the review and pointing out the situation. I checked the IsExplicitlyNullInConfig function, from the comment above the function, seems like it will return true when the field is absent. Source code here.
So, I did some test with debug log on, it did return true when the field is not presents. I guess the function name is kind of misleading....

}

if !features.FivePointOh() {
if !pluginsdk.IsExplicitlyNullInConfig(d, "moniter_metrics_after_duration") {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pluginsdk.IsExplicitlyNullInConfig is intended for CustomizeDiff scenarios where distinguishing "not set" vs "explicitly null" matters. The standard pattern for checking whether an optional field was provided in Create/Update functions is d.GetOk(). Using IsExplicitlyNullInConfig here deviates from established provider patterns

Copy link
Copy Markdown
Contributor Author

@LingyuTang LingyuTang Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I’m using this approach because it’s recommended in the https://hashicorp.github.io/terraform-provider-azurerm/topics/guide-breaking-changes/ in the contribution docs.
When drafting the change, I initially tried GetOk, but it failed the update test because GetOk can’t distinguish whether the user explicitly set the value in the config. In this case, if a user had previously set moniter_metrics_after_duration, that value would already exist in state. Later, when the user switches to monitor_metrics_after_duration (both map to the same state field), the old moniter_metrics_after_duration value would overwrite the user’s new change.

@@ -184,6 +185,94 @@ resource "azurerm_data_factory_pipeline" "test" {
}

func (PipelineResource) complete(data acceptance.TestData) string {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complete test config correctly branches on !features.FivePointOh() to use the deprecated field name. However, the update config always uses monitor_metrics_after_duration without a pre-5.0 branch. This means:

Pre-5.0 test flow: create with moniter_metrics_after_duration → update with monitor_metrics_after_duration
This implicitly tests a field migration rather than a pure update of the deprecated field
The update config should also have a !features.FivePointOh() branch using moniter_metrics_after_duration to properly test the deprecated field's update path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the update test to have !features.FivePointOh()

}

func (PipelineResource) complete(data acceptance.TestData) string {
if !features.FivePointOh() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also include this in a template?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, use the template for duplicate test string

@LingyuTang
Copy link
Copy Markdown
Contributor Author

Hey @liuwuliuyun thanks I have made the changes based on your review. Could you check my comment and the changed code when you have the time? Let me know if you have any questions!

@LingyuTang LingyuTang requested a review from liuwuliuyun April 22, 2026 08:59
@github-actions github-actions Bot added the size/L label May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azurerm_data_factory_pipeline: typo in a parameter

2 participants