SEC002: Missing Amazon.Lambda.DynamoDBEvents package
| Field | Value |
|---|---|
| Code | SEC002 |
| Severity | Error |
Message
Entity '{0}' is marked with [GenerateStreamConversion] but the Amazon.Lambda.DynamoDBEvents package is not referenced. Add a package reference to Amazon.Lambda.DynamoDBEvents version 3.1.1 or higher to enable stream conversion code generation.
Description
The [GenerateStreamConversion] attribute instructs the source generator to produce code that converts DynamoDB Stream event records into strongly-typed entity instances. This conversion code depends on the Amazon.Lambda.DynamoDBEvents package, which provides the Lambda AttributeValue types used in stream records.
This diagnostic is emitted as an error because the source generator cannot produce valid conversion code without the Lambda events package. The generated code would fail to compile since it references types from the missing package.
The minimum required version is 3.1.1, which introduced the necessary AttributeValue type definitions for stream processing.
Example
The following code triggers this diagnostic:
// Project file does NOT reference Amazon.Lambda.DynamoDBEvents
[DynamoDbTable("Orders")]
[GenerateStreamConversion]
public partial class Order
{
[PartitionKey]
[DynamoDbAttribute("pk")]
public string Pk { get; set; } = string.Empty;
[SortKey]
[DynamoDbAttribute("sk")]
public string Sk { get; set; } = string.Empty;
[DynamoDbAttribute("status")]
public string Status { get; set; } = string.Empty;
}
Fix
The corrected version:
<!-- Add the Lambda DynamoDBEvents package to your .csproj -->
<ItemGroup>
<PackageReference Include="Amazon.Lambda.DynamoDBEvents"
Version="3.1.1" />
</ItemGroup>
// With the package referenced, no error is emitted
[DynamoDbTable("Orders")]
[GenerateStreamConversion]
public partial class Order
{
[PartitionKey]
[DynamoDbAttribute("pk")]
public string Pk { get; set; } = string.Empty;
[SortKey]
[DynamoDbAttribute("sk")]
public string Sk { get; set; } = string.Empty;
[DynamoDbAttribute("status")]
public string Status { get; set; } = string.Empty;
}