-
Notifications
You must be signed in to change notification settings - Fork 874
Open
Labels
bugThis issue is a bug.This issue is a bug.needs-reviewpotential-regressionMarking this issue as a potential regression to be checked by team memberMarking this issue as a potential regression to be checked by team member
Description
Describe the bug
The comment even says it can be nullable in v4+, but the List isn't marked with a ?, and because it's lazy, this results in NullReferenceExceptions that the compiler doesn't catch, even when <Nullable>enable</Nullable>.
public partial class SendMessageBatchResponse : AmazonWebServiceResponse
{
private List<BatchResultErrorEntry> _failed = AWSConfigs.InitializeCollections ? new List<BatchResultErrorEntry>() : null;
private List<SendMessageBatchResultEntry> _successful = AWSConfigs.InitializeCollections ? new List<SendMessageBatchResultEntry>() : null;
/// <summary>
/// Gets and sets the property Failed.
/// <para>
/// A list of <c> <a>BatchResultErrorEntry</a> </c> items with error details about each
/// message that can't be enqueued.
/// </para>
/// <para />
/// Starting with version 4 of the SDK this property will default to null. If no data for this property is returned
/// from the service the property will also be null. This was changed to improve performance and allow the SDK and caller
/// to distinguish between a property not set or a property being empty to clear out a value. To retain the previous
/// SDK behavior set the AWSConfigs.InitializeCollections static property to true.
/// </summary>
[AWSProperty(Required=true)]
public List<BatchResultErrorEntry> Failed
{
get { return this._failed; }
set { this._failed = value; }
}Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
One of two things:
_log.LogInformation($"<snip> failures: {sendResult.Failed.Count}");This code should either be safe like it is in v3, OR the compiler should tell me I've got a problem, but because there's no ? on Failed, we don't get the null safety.
Current Behavior
We got an NRE.
Reproduction Steps
- Instantiate the response object. Leave the backing collection for
Failedas null. - Reference
Failed - Reference
Successful
The compiler won't warn you, and both will trigger NREs.
Possible Solution
Mark the properties with ?
Have your LLM look for similar traps in the rest of the library while you're at it.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Targeted .NET Platform
.NET 10
Operating System and version
macOS Tahoe 26.1
piekstra, zzwong and Dreamescaper
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.needs-reviewpotential-regressionMarking this issue as a potential regression to be checked by team memberMarking this issue as a potential regression to be checked by team member