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

Fix for DI registration not completing as expected #1386

Merged
merged 11 commits into from
Nov 5, 2024

Conversation

WhitWaldo
Copy link
Contributor

@WhitWaldo WhitWaldo commented Oct 27, 2024

Description

#1363 changed how clients registered themselves under the hood with DI to make for a more uniform process. With Workflow, this meant switching to a factory that attempts to load values from an injected IConfiguration.

Fix breakdown

  • Updated to make IConfiguration injection optional as the caller might not be using ASP.NET Core and thus may not have actually registered this
  • Updated to make IHttpClientFactory optional because while it's registered as part of using AddWorkflowClient, the caller might not be using that route (though they should)
  • When the IConfiguration change was originally made, the idea was to use a factory that the IConfiguration and IHttpClientFactory are injected to as those would be resolved and used as part of the registration of the durable task functionality. Unfortunately, two key steps were overlooked: The factory itself was never registered and the method performing the necessary additional registrations was never invoked because it lived in a DI registration that would never resolve to invoke it. Corrected this by registering the factory as intended and by creating a scoped provider during registration that resolves and invokes the method ensuring that the types are registered on the IServiceCollection as intended.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1385

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests - WIP
  • [N/A] Extended the documentation

@WhitWaldo WhitWaldo self-assigned this Oct 27, 2024
@WhitWaldo WhitWaldo requested review from a team as code owners October 27, 2024 16:44
@WhitWaldo WhitWaldo added this to the v1.15 milestone Oct 27, 2024
Signed-off-by: Whit Waldo <[email protected]>
@WhitWaldo WhitWaldo changed the title Tentative fix for DI registration not completing as expected Fix for DI registration not completing as expected Oct 27, 2024
Copy link
Collaborator

@philliphoff philliphoff left a comment

Choose a reason for hiding this comment

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

I wonder if we might simplify the registration here a bit.

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.05%. Comparing base (1b7c9f4) to head (998f46c).
Report is 61 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1386      +/-   ##
==========================================
+ Coverage   67.28%   71.05%   +3.77%     
==========================================
  Files         174      188      +14     
  Lines        6025     6389     +364     
  Branches      671      697      +26     
==========================================
+ Hits         4054     4540     +486     
+ Misses       1802     1684     -118     
+ Partials      169      165       -4     
Flag Coverage Δ
net6 71.04% <ø> (+3.77%) ⬆️
net7 71.04% <ø> (+3.77%) ⬆️
net8 71.04% <ø> (+3.77%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@philliphoff philliphoff left a comment

Choose a reason for hiding this comment

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

Needs fix for build break, but otherwise looks good. Wish we didn't have to create a services scope to pull dependencies from the container, but I don't see a way to defer it any further.

@WhitWaldo WhitWaldo merged commit 682df6f into dapr:master Nov 5, 2024
10 checks passed
@WhitWaldo WhitWaldo deleted the workflow-bug branch November 5, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow DI Registration Bug
2 participants