-
Notifications
You must be signed in to change notification settings - Fork 280
Add CustomStatus Size Check for OOP model #3113
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#nullable enable | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using DurableTask.Core; | ||
using DurableTask.Core.Command; | ||
using DurableTask.Core.Entities; | ||
|
@@ -73,6 +74,8 @@ internal bool TryGetOrchestrationErrorDetails(out Exception? failure) | |
|
||
internal void SetResult(IEnumerable<OrchestratorAction> actions, string customStatus) | ||
{ | ||
this.ValidateCustomStatusSize(customStatus); | ||
|
||
var result = new OrchestratorExecutionResult | ||
{ | ||
CustomStatus = customStatus, | ||
|
@@ -182,5 +185,20 @@ private void SetResultInternal(OrchestratorExecutionResult result) | |
|
||
this.executionResult = result; | ||
} | ||
|
||
private void ValidateCustomStatusSize(string customStatus) | ||
{ | ||
// Azure Table Storage enforces a 32 KB limit if a property value is a UTF-16 encoded string. | ||
// We apply a 16 KB limit here to align with our in-process model. | ||
const int MaxCustomStatusSizeInKB = 16; | ||
double customStatusSizeInKB = customStatus != null ? Encoding.Unicode.GetByteCount(customStatus) / 1024.0 : 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big deal, but do we really need floating-point computation here? Consider defining the constant as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review, Anatoli! This was changed like this because of this comment . |
||
|
||
// If the provided custom status value exceeds 16KB in size, fail the orchestration. | ||
if (customStatusSizeInKB > MaxCustomStatusSizeInKB) | ||
{ | ||
throw new ArgumentException( | ||
$"CustomStatus is too large: limit = {MaxCustomStatusSizeInKB} KB (UTF-16), actual = {customStatusSizeInKB:N2} KB."); | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.