Skip to content

GetWorkflowStateAsync should always return WorkflowState#1847

Merged
WhitWaldo merged 7 commits into
masterfrom
fix-workflow-state
Jun 13, 2026
Merged

GetWorkflowStateAsync should always return WorkflowState#1847
WhitWaldo merged 7 commits into
masterfrom
fix-workflow-state

Conversation

@WhitWaldo

@WhitWaldo WhitWaldo commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

Ensuring that GetWorkflowStateAsync always returns a WorkflowState so the WorkflowState.Exists properly reflects the presence of the value (or not). This was erroneously returning null if the metadata wasn't available when this is, in fact, a supported value in the WorkflowState object, so I'm applying this fix. The signature doesn't change, just the behavior, so this shouldn't be a dramatic breaking change.

Thank you to @atrauzzi for the helpful discussion in which this was pointed out.

Also, after a very long discussion with @atrauzzi about the merits of logging at the SDK level, he's won me over and I'm also removing the error that was previously logged when using GetWorkflowStateAsync when the workflow was returned as not existing. He's right in his assertion that an error was too severe for an operation that completed successfully. The error remains if the runtime returns an unexpected value (null or some other response shape), but will no longer log if it's just a matter of a workflow instance not existing in the runtime.

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: #[issue number]

Checklist

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

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

…so the `WorkflowState.Exists` properly reflects the presence of the value (or not).

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo WhitWaldo requested review from a team as code owners June 10, 2026 18:02
@WhitWaldo WhitWaldo added this to the v1.18 milestone Jun 10, 2026
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.18%. Comparing base (027c724) to head (7ed6707).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1847      +/-   ##
==========================================
- Coverage   63.19%   63.18%   -0.02%     
==========================================
  Files         330      330              
  Lines        9534     9534              
  Branches     1110     1110              
==========================================
- Hits         6025     6024       -1     
  Misses       3198     3198              
- Partials      311      312       +1     
Flag Coverage Δ
net10.0 63.14% <ø> (-0.02%) ⬇️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…re's an unexpected response from the runtime

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo WhitWaldo self-assigned this Jun 10, 2026
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@atrauzzi

Copy link
Copy Markdown
Contributor

Love it! As always @WhitWaldo, thank you for your vigilance as the keeper of the Dapr dotnet scrolls! ✊

catch (RpcException ex) when (ex.StatusCode == StatusCode.NotFound)
{
logger.LogGetWorkflowMetadataInstanceNotFound(ex, instanceId);
return null;

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.

😍

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Finally it's removed 👍 - QA always open bugs about it, thinking it's from the Microservice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@barakbbn If there are other issues like this you're experiencing, please don't hesitate to file an issue about it so I can address them too!

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.

3 participants