.NET: Fix issue with resuming checkpoint after package version upgrade#6670
Draft
peibekwe wants to merge 1 commit into
Draft
.NET: Fix issue with resuming checkpoint after package version upgrade#6670peibekwe wants to merge 1 commit into
peibekwe wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Ports the workflows checkpoint-compatibility fix to the DurableTask implementation so persisted assembly-qualified type names (from checkpoints/custom status payloads) can be resolved after package upgrades where only assembly version/culture/PKT metadata changed.
Changes:
- Add
DurableTaskTypeResolverto normalize persisted type names and resolve them against loaded assemblies. - Use the resolver when deserializing streamed workflow events and when resolving executor input types.
- Add unit tests covering mutated assembly versions (outer and generic-argument cases) and the streaming deserialization path.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableTaskTypeResolver.cs | New resolver that normalizes persisted assembly-qualified names and caches resolution. |
| dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableStreamingWorkflowRun.cs | Switch event type lookup to use the new resolver during stream parsing. |
| dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs | Use the resolver to match persisted input type names to supported executor input types across version changes. |
| dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableTaskTypeResolverTests.cs | New tests validating type resolution across assembly metadata mutations. |
| dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableActivityExecutorResolveInputTypeTests.cs | New tests validating input-type matching behavior across metadata mutations. |
| dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableStreamingWorkflowRunTests.cs | New test validating mutated event type names still deserialize during WatchStreamAsync. |
Comment on lines
+16
to
+38
| private static readonly ConcurrentDictionary<string, Type?> s_cache = new(); | ||
|
|
||
| /// <summary> | ||
| /// Resolves <paramref name="typeName"/> using a qualified <see cref="Type.GetType(string, bool)"/> | ||
| /// lookup, then a partial-name fallback that strips embedded version, culture, and public key | ||
| /// token qualifiers. | ||
| /// </summary> | ||
| [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access", Justification = "Workflow message and event types are registered at startup.")] | ||
| [UnconditionalSuppressMessage("Trimming", "IL2057:Unrecognized value passed to the parameter of method", Justification = "Workflow message and event types are registered at startup.")] | ||
| internal static Type? Resolve(string typeName) | ||
| => s_cache.GetOrAdd(typeName, static name => | ||
| { | ||
| Type? type = Type.GetType(name, throwOnError: false); | ||
| if (type is not null) | ||
| { | ||
| return type; | ||
| } | ||
|
|
||
| string normalized = TypeId.NormalizeTypeName(name); | ||
| return ReferenceEquals(normalized, name) | ||
| ? null | ||
| : Type.GetType(normalized, throwOnError: false); | ||
| }); |
Comment on lines
+9
to
+13
| /// <summary> | ||
| /// Resolves persisted assembly-qualified type-name strings to a loaded <see cref="Type"/>, | ||
| /// tolerating differences in assembly version, culture, and public key token between the | ||
| /// persisted name and the currently loaded assemblies. Results are cached. | ||
| /// </summary> |
Comment on lines
+17
to
+22
| public void ResolveInputType_NullInput_ReturnsFirstSupportedType() | ||
| { | ||
| Type result = DurableActivityExecutor.ResolveInputType(null, new HashSet<Type> { typeof(int), typeof(string) }); | ||
|
|
||
| Assert.Equal(typeof(int), result); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
When you upgrade the
Microsoft.Agents.AI.DurableTaskpackage and redeploy, any saved workflow checkpoint from the previous version becomes unusable. The framework refuses to load it, even though nothing about the workflow actually changed; only the package's version number did.Description & Review Guide
This ports the fix applied to core workflows in PR #6636 to
DurableTask.Fixes #6669
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.