Repository navigation
fix(dynamodb)!: require ServiceId for DynamoDB grain storage - #11551
Conversation
DynamoDBStorageOptions.ServiceId is now null by default, and the options validator stops the silo until it is set. An empty string is still valid and keeps the keys written while it defaulted to an empty string; the configuration builder now applies it instead of skipping it. Fixes dotnet#9971
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues in the focused validation change, explicit legacy-key support, or accompanying tests.
No open issues 🎉
What changed in this PR
Addresses #9971 by requiring an explicit ServiceId for DynamoDB grain storage while preserving legacy keys when an empty string is selected.
Changes:
- Rejects an unset
ServiceIdand accepts explicitly empty configuration values. - Adds validation tests and preserves existing integration-test keys.
- Updates documentation, examples, and the generated API surface.
Execution and coverage results were unavailable.
| File | Description |
|---|---|
| test/Extensions/Orleans.Streaming.Kinesis.Tests/KinesisStreamTests.cs | Explicitly preserves legacy storage keys. |
| test/Extensions/Orleans.AWS.Tests/Streaming/SQSStreamTests.cs | Explicitly preserves legacy storage keys. |
| test/Extensions/Orleans.AWS.Tests/Streaming/SQSFIFOStreamTests.cs | Explicitly preserves legacy storage keys. |
| test/Extensions/Orleans.AWS.Tests/StorageTests/PersistenceGrainTests_AWSDynamoDBStore.cs | Explicitly preserves legacy storage keys. |
| test/Extensions/Orleans.AWS.Tests/StorageTests/DynamoDBGrainStorageProviderBuilderTests.cs | Tests defaults, validation, and empty configuration. |
| src/AWS/Orleans.Persistence.DynamoDB/README.md | Sets ServiceId in the example. |
| src/AWS/Orleans.Persistence.DynamoDB/Options/DynamoDBStorageOptions.cs | Requires and documents explicit configuration. |
| src/AWS/Orleans.Persistence.DynamoDB/Hosting/DynamoDBGrainStorageProviderBuilder.cs | Retains explicitly empty configuration values. |
| src/api/AWS/Orleans.Persistence.DynamoDB/Orleans.Persistence.DynamoDB.cs | Reflects nullable ServiceId. |
| docs/site/src/content/docs/snippets/compiled/Streaming/SqsSnippets.cs | Configures a storage service identifier. |
| docs/site/src/content/docs/grains/grain-persistence/dynamodb-storage.md | Explains startup validation and legacy-key preservation. |
Review effort: Balanced
ReubenBond
left a comment
There was a problem hiding this comment.
Reviewed the startup-validation contract and storage-key compatibility. ServiceId is now explicit, while string.Empty preserves the previous key namespace; key construction and persistence behavior are unchanged. The earlier migration proposals #11352 and #11353 are closed in favor of this focused fix. Tightened upgrade guidance and added assertions for the registered validator, explicit-empty configuration, and the upgrade diagnostic. Targeted tests pass on net8.0 and net10.0; Release pack passes against the 10.4.0 baseline and CI-style API regeneration matches the checked-in surface, so no compatibility suppression is needed. No blocking code findings. The final base update remains coordinated with release preparation, and required CI must be green before merging.
Code coverage
Report-only conclusion: improved. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
Fixes #9971
Problem
DynamoDBStorageOptions.ServiceIddefaults to an empty string, and DynamoDB grain storage builds its keys as{ServiceId}_{grainId}. A silo that doesn't set it stores every grain state under a key that starts with an underscore, with no sign that something is missing.Solution
As suggested in #9971, the provider now refuses to start until
ServiceIdis set:ServiceIdisnullby default, andDynamoDBGrainStorageOptionsValidatorthrows anOrleansConfigurationExceptionwhen it is not set. The message says to set it to the cluster'sServiceId, or to an empty string to keep the keys written while it defaulted to an empty string.ServiceIdis still valid, so an existing deployment keeps its state by setting it tostring.Empty.ServiceIdfrom configuration instead of skipping it, so the same choice is available there.ServiceId. The tests that start a silo with DynamoDB grain storage set it to an empty string, so they keep their keys.DynamoDBGrainStorageProviderBuilderTestscover the unset default, the validation, and an emptyServiceIdfrom configuration.This is a breaking change: a silo with DynamoDB grain storage and no
ServiceIdfails at startup, with the message above.Microsoft Reviewers: Open in CodeFlow