Skip to content

V4: Fixed an issue where NullReferenceException was thrown while invoking AmazonCloudFormationClient.UpdateStackAsync(). #3835

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

ashishdhingra
Copy link
Contributor

@ashishdhingra ashishdhingra commented May 21, 2025

Description

Fixed an issue where NullReferenceException was thrown while invoking AmazonCloudFormationClient.UpdateStackAsync().

Motivation and Context

Issue #3824

Testing

  • Added integration test.
  • Dry-run DRY_RUN-85255203-68f8-4723-b60b-bac707e8620b completed successfully.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@@ -72,9 +72,16 @@ protected virtual void PreInvoke(IExecutionContext executionContext)

// if there are no NotificationARNs and the list was created by user (type is NOT AutoConstructed)
// only then pass empty param
if (arns.Count == 0 && !arnsAutoConstructed)
if ((arns == null || arns.Count == 0) && !arnsAutoConstructed)
Copy link
Member

Choose a reason for hiding this comment

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

Since null means we don't want to send string.Empty for NotificationARNs this logic can be simplified. Here is my suggestion without testing it.

if (updateStackRequest != null)
{
	var arns = updateStackRequest.NotificationARNs;
	if (arns != null)
	{
		// if there are no NotificationARNs and the list was created by user (type is NOT AutoConstructed)
		// only then pass empty param
		if (arns.Count == 0 && !(arns is AutoConstructedList<string>))
		{
			request.Parameters.Add("NotificationARNs", "");
			if (request.Parameters.ContainsKey("NotificationARNs"))
			{
				request.Parameters["NotificationARNs"] = string.Empty;
			}
			else
			{
				request.Parameters.Add("NotificationARNs", string.Empty);
			}
		}				
	}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Re-executing dry-run.

@peterrsongg peterrsongg self-requested a review May 22, 2025 17:24
… AmazonCloudFormationClient.UpdateStackAsync().
@ashishdhingra ashishdhingra force-pushed the user/ashdhin/V4-3824-CFN-UpdateStackAsync-NRE branch from 4c6372a to ab5d417 Compare May 22, 2025 17:41
@ashishdhingra ashishdhingra requested a review from normj May 22, 2025 17:42
@ashishdhingra ashishdhingra added bug This issue is a bug. module/sdk-custom labels May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/sdk-custom v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants