Skip to content

Conversation

@EspenAlbert
Copy link
Collaborator

Description

Adds invalid update error for delete_on_create_timeout for sdkv2

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

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

@EspenAlbert EspenAlbert marked this pull request as ready for review October 24, 2025 08:45
@EspenAlbert EspenAlbert requested a review from a team as a code owner October 24, 2025 08:45
@Copilot Copilot AI review requested due to automatic review settings October 24, 2025 08:45
Copy link
Contributor

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

This PR adds validation to prevent updates to the delete_on_create_timeout attribute in SDKv2 resources (online archive and network peering). The attribute should only be set during resource creation and cannot be modified afterward.

Key changes:

  • Implements DeleteOnCreateTimeoutInvalidUpdate function to validate that delete_on_create_timeout cannot be updated after creation
  • Adds validation logic to the resourceUpdate functions for both online archive and network peering resources
  • Includes comprehensive test coverage for the new validation behavior

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/common/cleanup/handle_timeout.go Adds new validation function and error message constant for invalid delete_on_create_timeout updates
internal/common/cleanup/handle_timeout_test.go Adds comprehensive unit tests for the new validation function using mock resources
internal/service/onlinearchive/resource.go Integrates validation check in the update function to prevent invalid attribute changes
internal/service/networkpeering/resource.go Integrates validation check in the update function to prevent invalid attribute changes
internal/service/networkpeering/resource_test.go Adds integration test case to verify the validation error is properly returned and updates import state verification

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

const (
CleanupWarning = "Failed to create resource. Will run cleanup due to the operation timing out"
CleanupWarning = "Failed to create resource. Will run cleanup due to the operation timing out"
DeleteOnCreateTimeoutInvalidErrorMessage = "delete_on_create_timeout cannot be updated or set after import, remove it from the configuration"
Copy link
Collaborator

Choose a reason for hiding this comment

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

q: why are we erroring only after it's changed in import but yes on creation?

// DeleteOnCreateTimeoutInvalidUpdate returns an error if the `delete_on_create_timeout` attribute has been updated to true/false
// This use case differs slightly from the behavior of TPF customplanmodifier.CreateOnlyBoolWithDefault:
// - from a given value (true/false) --> `null`.
// This TPF implementation keeps the state value (UseStateForUnknown behavior).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// This TPF implementation keeps the state value (UseStateForUnknown behavior).
// While the TPF implementation keeps the state value (UseStateForUnknown behavior),

// This use case differs slightly from the behavior of TPF customplanmodifier.CreateOnlyBoolWithDefault:
// - from a given value (true/false) --> `null`.
// This TPF implementation keeps the state value (UseStateForUnknown behavior).
// This will set the state value to null (Optional-only attribute).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// This will set the state value to null (Optional-only attribute).
// The SDKv2 implementation will set the state value to null (Optional-only attribute).

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.

2 participants