Skip to content

Conversation

lantoli
Copy link
Collaborator

@lantoli lantoli commented Aug 26, 2025

Description

Handle errors for unsupported dynamic block use cases. This is in line with the dynamic block limitations described in the documentation.

Link to any related issue(s): CLOUDP-341042

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@github-actions github-actions bot added the enhancement New feature or request label Aug 26, 2025
@lantoli lantoli marked this pull request as ready for review August 26, 2025 13:15
@Copilot Copilot AI review requested due to automatic review settings August 26, 2025 13:15
@lantoli lantoli requested a review from a team as a code owner August 26, 2025 13:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds validation to prevent invalid dynamic block configurations in Terraform conversion utilities. The feature ensures that dynamic blocks cannot coexist with inline blocks for the same configuration type, which would result in invalid Terraform syntax.

  • Adds new error types and messages for dynamic block validation
  • Implements checks to enforce dynamic blocks as the only block type when present
  • Includes comprehensive test cases for all invalid configuration scenarios

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/convert/shared.go Defines new error variable for dynamic block validation
internal/convert/clu2adv.go Adds validation checks for replication_specs and regions_config dynamic blocks
internal/convert/adv2v2.go Adds validation checks for replication_specs and region_configs dynamic blocks
internal/convert/convert_test.go Enhances test framework to ensure all error messages are tested
internal/convert/testdata/*/errors.json Adds error messages for new validation scenarios
internal/convert/testdata//.in.tf Provides test cases for invalid dynamic block configurations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lantoli lantoli changed the title feat: Raise errors for unsupported dynamic block use cases feat: Handle errors for unsupported dynamic block use cases Aug 26, 2025
for name := range errMap {
unusedErrors[name] = struct{}{}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

make sure all items in errors.json are used

Copy link
Contributor

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM

@lantoli lantoli merged commit 89c734f into main Aug 27, 2025
7 checks passed
@lantoli lantoli deleted the CLOUDP-341042_errors branch August 27, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants