Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: alert configuration data source nil pointer with third party notifications #1513

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

AgustinBettati
Copy link
Member

Description

Jira ticket: INTMDB-1182
Bug found when validating fix for INTMDB-981.

This nil pointer error is encountered when using the alert configuration data source for a third party alert configuration notification that does not define the interval_min attribute.
An acceptance test reproducing this issue was defined but skipped in CI as it relies on external credentials. Was able to verify that dummy credentials can be used to successfully create third party alert notifications so adjusted the corresponding tests so they all run in our CI moving forward.

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.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • 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 defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

@AgustinBettati AgustinBettati requested a review from a team as a code owner October 9, 2023 12:26
@@ -744,9 +745,9 @@ func newTFNotificationModelListV2(n []admin.AlertsNotificationRootForGroup, curr
Roles: value.Roles,
ChannelName: conversion.StringPtrNullIfEmpty(value.ChannelName),
DatadogRegion: conversion.StringPtrNullIfEmpty(value.DatadogRegion),
DelayMin: types.Int64Value(int64(*value.DelayMin)),
DelayMin: types.Int64PointerValue(util.IntPtrToInt64Ptr(value.DelayMin)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure why you need Int64PointerValue and util.IntPtrToInt64Ptr.

Copy link
Member Author

Choose a reason for hiding this comment

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

IntervalMin and DelayMin are of type *int, as in some case they may not be defined. Int64PointerValue and util.IntPtrToInt64Ptr are used to safely store the optional value into the model, without insecurely accessing the underlying value as done in *value.DelayMin.

@AgustinBettati
Copy link
Member Author

cloud-dev seems unstable with project creations, will wait some time and run CI again.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/framework/validator 68%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util 14%
Summary 3% (271 / 10285)

@@ -398,23 +402,22 @@ func TestAccConfigRSAlertConfiguration_importPagerDuty(t *testing.T) {
}

func TestAccConfigRSAlertConfiguration_DataDog(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

similar to before, are we still testing Datadog integration?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, terraform configurations being tested are the same. Change here is that api key is now a hardcoded dummy value, when testing in cloud-dev found that there is no need to pass a real api key, as long as the format is correct the alert notifications are created successfully.

@@ -28,6 +28,15 @@ func Int64PtrToIntPtr(i64 *int64) *int {
return &i
}

func IntPtrToInt64Ptr(i *int) *int64 {
Copy link
Member

Choose a reason for hiding this comment

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

this seems the inverse to admin.Int64PtrToIntPtr. , don't know if it makes sense to have it in the SDK

Copy link
Member Author

Choose a reason for hiding this comment

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

this conversion only seems needed when using old sdk (that uses int type), so eventually will be removed.

@AgustinBettati AgustinBettati merged commit a308471 into master Oct 11, 2023
33 checks passed
@AgustinBettati AgustinBettati deleted the INTMDB-1182 branch October 11, 2023 08:55
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.

3 participants