Skip to content

fix(dynamodb)!: require ServiceId for DynamoDB grain storage - #11551

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
Laurianti:dynamodb-require-service-id
Oct 21, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
Laurianti:dynamodb-require-service-id

Conversation

@Laurianti

@Laurianti Laurianti commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9971

Problem

DynamoDBStorageOptions.ServiceId defaults 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 ServiceId is set:

  • ServiceId is null by default, and DynamoDBGrainStorageOptionsValidator throws an OrleansConfigurationException when it is not set. The message says to set it to the cluster's ServiceId, or to an empty string to keep the keys written while it defaulted to an empty string.
  • An empty ServiceId is still valid, so an existing deployment keeps its state by setting it to string.Empty.
  • The configuration provider builder now applies an empty ServiceId from configuration instead of skipping it, so the same choice is available there.
  • The XML docs, the provider README, the DynamoDB grain persistence page and the SQS snippet set or describe ServiceId. The tests that start a silo with DynamoDB grain storage set it to an empty string, so they keep their keys.
  • DynamoDBGrainStorageProviderBuilderTests cover the unset default, the validation, and an empty ServiceId from configuration.

This is a breaking change: a silo with DynamoDB grain storage and no ServiceId fails at startup, with the message above.

Microsoft Reviewers: Open in CodeFlow

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 ServiceId and 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

Copilot AI balanced review requested due to automatic review settings October 21, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The intentional startup-breaking change warrants maintainer approval, and completed CI validation was not established.

No open issues 🎉

Review effort: Balanced

@ReubenBond ReubenBond left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@github-actions

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 83.98% (120,428 / 143,394) 83.98% (120,425 / 143,391) +0.0003 pp
Branches 73.79% (36,025 / 48,820) 73.78% (36,019 / 48,818) +0.0093 pp

Report-only conclusion: improved.

The current-main baseline is commit 1255777d9a and uses the same reviewed coverage matrix.

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

@ReubenBond
ReubenBond merged commit bb9c128 into dotnet:main Oct 21, 2026
95 checks passed
@Laurianti
Laurianti deleted the dynamodb-require-service-id branch November 7, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamoDBStorageOptions ServiceId default

3 participants