Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax type check in OrchestrationInputConverter #3061

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Ilia-Kosenkov
Copy link

OrchestrationInputConverter responsible for processing orchestration inputs in isolated model has a strict type check that verifies that deserialized value's type equals exactly to the target type in the function prototype. While it is correct for the majority of cases, it is not so when the target type is a collection interface. Standard behavior of, e.g., System.Text.Json serializer to produce a List<T> when target deserialization type is, e.g., IEnumerable<T>. Now, List<T> implements IEnumerable<T> and this can safely be passed to the orchestration, however since typeof(List<T>) != typeof(IEnumerable<T>), the check fails and orchestration receives a null input.

This PR addresses this issue by slightly relaxing the type check, reporting a successful conversion of actual deserialized value can be assigned to target type due to inheritance or interface implementation. This unblocks collection interfaces and custom json serializers that might return a more concrete type than target deserialization type (i.e. custom polymorphic deserialization).

Issue describing the changes in this PR

resolves #3035

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation PR is ready to merge and referenced in pending_docs.md
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)
  • My changes do not require any extra work to be leveraged by OutOfProc SDKs
    • Otherwise: That work is being tracked here: #issue_or_pr_in_each_sdk
  • My changes do not change the version of the WebJobs.Extensions.DurableTask package
    • Otherwise: major or minor version updates are reflected in /src/Worker.Extensions.DurableTask/AssemblyInfo.cs
  • My changes do not add EventIds to our EventSource logs
    • Otherwise: Ensure the EventIds are within the supported range in our existing Windows infrastructure. You may validate this with a deployed app's telemetry. You may also extend the range by completing a PR such as this one.
  • My changes should be added to v2.x branch.
    • Otherwise: This change applies exclusively to WebJobs.Extensions.DurableTask v3.x. It will be retained only in the dev and main branches and will not be merged into the v2.x branch.

@Ilia-Kosenkov
Copy link
Author

@lilyjma , hello, here is my suggestion for #3035 . If this is acceptable, I probably will need some help dealing with necessary ceremonies.
I added unit tests, ensured that they fail on current dev branch -> added fix -> ensured tests are green.
If other tests are required (or if I should put these someplace else, please let me know).

I also produced a test nuget, referenced it locally in my test project, and verified that now the particular issue mentioned in #3035 is fixed.

Thanks in advance.

@Ilia-Kosenkov
Copy link
Author

@microsoft-github-policy-service agree company="Sievo"

@Ilia-Kosenkov Ilia-Kosenkov force-pushed the fix/3035-Allow-collection-interfaces-in-durable-orchestration-inputs branch from bc082b6 to b4c59ec Compare March 3, 2025 08:55
@Ilia-Kosenkov Ilia-Kosenkov force-pushed the fix/3035-Allow-collection-interfaces-in-durable-orchestration-inputs branch from b4c59ec to 179d093 Compare March 3, 2025 09:06
@lilyjma
Copy link
Contributor

lilyjma commented Mar 4, 2025

thanks @Ilia-Kosenkov for the contribution. I'll ask someone on the team to review your PR.

@Ilia-Kosenkov
Copy link
Author

Hey @lilyjma , a friendly reminder about this PR. The change is small, it would be nice to get an assessment whether it aligns with the direction the framework is taking right now. And to us, it is a small but nice quality of life improvement. Thanks!

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.

Orchestration input IInputConverter does not handle colletion iterfaces
2 participants