Skip to content

Conversation

@congx4
Copy link
Contributor

@congx4 congx4 commented Oct 10, 2025

This PR addresses the issue when we import rulesets without any rules. This happens when the API returns fields the generated client doesn't know about (like rules:null). In this case, the entire Data object fails to unmarshall and everything goes into UnparsedObject.

The added logic here is to parse fields from UnparsedObject.

Before the fix, the tf state after importing a ruleset without rules is like:

{
  "version": 4,
  "terraform_version": "1.13.2",
  "serial": 1,
  "lineage": "7bc106c5-1c7f-0869-e41d-cc0c1bf97e39",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "datadog_tag_pipeline_ruleset",
      "name": "rule1",
      "provider": "provider[\"registry.terraform.io/datadog/datadog\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "enabled": null,
            "id": "43116ae4-a25f-4b78-9c05-85d7d28643eb",
            "name": null,
            "position": null,
            "rules": [],
            "version": null
          },
          "sensitive_attributes": [],
          "identity_schema_version": 0
        }
      ]
    }
  ],
  "check_results": null
}



after:


{
  "version": 4,
  "terraform_version": "1.13.2",
  "serial": 1,
  "lineage": "cc5d6ce8-0eb4-d2f7-1a8f-f963fef94535",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "datadog_tag_pipeline_ruleset",
      "name": "rule1",
      "provider": "provider[\"registry.terraform.io/datadog/datadog\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "enabled": true,
            "id": "43116ae4-a25f-4b78-9c05-85d7d28643eb",
            "name": "rule1",
            "position": 3,
            "rules": [],
            "version": 2715510
          },
          "sensitive_attributes": [],
          "identity_schema_version": 0
        }
      ]
    }
  ],
  "check_results": null
}

@congx4 congx4 marked this pull request as ready for review October 10, 2025 17:09
@congx4 congx4 requested review from a team as code owners October 10, 2025 17:09
@congx4 congx4 changed the title Fix import tag pipeline rulesets without any rules Fix an edge case when imports tag pipeline rulesets without any rules Oct 10, 2025
@congx4 congx4 changed the title Fix an edge case when imports tag pipeline rulesets without any rules [datadog_tag_pipeline_ruleset] Fix an edge case when imports tag pipeline rulesets without any rules Oct 10, 2025
@congx4
Copy link
Contributor Author

congx4 commented Oct 14, 2025

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Oct 14, 2025

View all feedbacks in Devflow UI.

2025-10-14 14:36:02 UTC ℹ️ Start processing command /merge


2025-10-14 14:36:07 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 26m (p90).


2025-10-14 15:02:45 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit 7bdf56e into master Oct 14, 2025
16 of 19 checks passed
@dd-mergequeue dd-mergequeue bot deleted the congxie/fixTFImport branch October 14, 2025 15:02
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.

4 participants