Repository navigation
Fix Durable client current-app detection - #3528
wangbill (YunchuWang) wants to merge 10 commits into
Conversation
Compare durable client targets with the host default provider and let providers define TaskHub identity casing. Cover cross-connection routing and shared HTTP, gRPC, orchestrator, restart, and entity validation behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR corrects Durable client “current app” detection so local metadata validation (missing/disabled orchestrator/entity checks) only runs when the target client actually points at the host’s default backend, and so TaskHub identity respects provider-specific casing semantics (Azure Storage case-insensitive vs exact-case providers).
Changes:
- Fix
DurableClient.ClientReferencesCurrentAppto compare againstDurableTaskExtension.DefaultDurabilityProvider(connection + TaskHub), not the target provider against itself. - Introduce provider-overridable TaskHub identity matching (
DurabilityProvider.TaskHubNameMatches), with Azure Storage overriding to ordinal-ignore-case. - Add/adjust unit tests for cross-connection behavior and TaskHub case-variant behavior across direct, HTTP, and gRPC paths.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/FunctionsV2/Tests/Unit/LocalGrpcListenerTests.cs | Adds gRPC coverage for “different connection” disabled-orchestrator start reaching the target provider and refines TaskHub casing scenarios. |
| test/FunctionsV2/Tests/Unit/HttpApiHandlerTests.cs | Updates HTTP tests for different-connection behavior and adds Azure Storage case-variant TaskHub local rejection coverage for disabled orchestrators. |
| test/FunctionsV2/Tests/Unit/DurableClientBaseTests.cs | Updates direct-client tests to validate corrected current-app gating across connections and provider-specific TaskHub casing semantics. |
| src/WebJobs.Extensions.DurableTask/DurabilityProvider.cs | Adds TaskHubNameMatches as the provider-specific TaskHub identity predicate (base: ordinal). |
| src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableClient.cs | Uses host default durability provider for connection + TaskHub matching and gates current-app detection on config != null. |
| src/WebJobs.Extensions.DurableTask/AzureStorageDurabilityProvider.cs | Overrides TaskHubNameMatches to use ordinal-ignore-case for Azure Storage TaskHub identity. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
e9cd0a5 to
917a5e6
Compare
Exercise provider-aware TaskHub casing and cross-account routing with real Functions hosts against two isolated Azurite backends. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8dd495b5-0788-4ec5-bfdc-5dd9728bb509
Mirror the GitHub FunctionsV2 E2E setup in the merged Azure Pipelines job while leaving analyzer CI unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8dd495b5-0788-4ec5-bfdc-5dd9728bb509
Resolve the CI migration conflict by retaining dev's deleted GitHub workflow and preserving secondary Azurite setup in the replacement public FunctionsV2 E2E job. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8dd495b5-0788-4ec5-bfdc-5dd9728bb509
Await task hub deletion before deterministically disposing the locally-created orchestration service. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8dd495b5-0788-4ec5-bfdc-5dd9728bb509
Preserve exact-case task hub identity when explicit entity operations select a target client. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8dd495b5-0788-4ec5-bfdc-5dd9728bb509
Use an internal ordinal cache key for provider-relevant configuration while restoring the public attribute equality/hash contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8dd495b5-0788-4ec5-bfdc-5dd9728bb509
Add hosted regression coverage for both internal/external client creation orders (#1926). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4f73040c-3459-4728-8c53-8e481e672736
There was a problem hiding this comment.
🟡 Changes recommended
The explicit-client fast path can still alias case-distinct connections for exact-case providers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 1
- Review effort level: Balanced
| if (this.DurabilityProvider.TaskHubNameMatches(this.TaskHubName, taskHubName) | ||
| && string.Equals(this.attribute.ConnectionName, connectionName, StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
🔵 Needs a closer look
Explicit operations can still reuse the wrong client when connection names differ only by casing.
Review details
Suppressed comments (1)
src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableClient.cs:107
- The new provider-aware hub check can still return the wrong client when only the requested connection's casing differs.
ConnectionNameMatchesdefines the base provider identity with case-sensitive equality (DurabilityProvider.cs:614-617), and the new cache key likewise preserves connection casing, but this fast path still treatsStorageandstorageas identical. Explicit-hub entity signals (and other callers ofGetDurableClient) can therefore reuse the current provider instead of resolving the requested backend. Use an ordinal connection comparison here so a case-variant request reaches the provider factory and is classified consistently.
if (this.DurabilityProvider.TaskHubNameMatches(this.TaskHubName, taskHubName)
- Files reviewed: 15/15 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Summary
Fixes #3523.
Fixes #1926.
This compatibility correction builds on merged PR #3514 (
477a92915cbeb46423fe55ceb36c036b845b00b0). It keeps the single sharedDurableClient.ClientReferencesCurrentAppgate introduced there, but compares a target client with the host's actual default durability provider instead of comparing the target provider with itself.Before / after
ExternalClient = truewith a matching internal cache entryDesign rationale
ClientReferencesCurrentAppremains the only predicate used by missing-orchestrator, missing-entity, and startup-disabled-orchestrator validation.DurableTaskExtension.DefaultDurabilityProvider, passing the target provider. This preserves provider-specific connection matching direction.TaskHub,ConnectionName,ExternalClient, andDurableRequiresGrpc. Host and factory caches therefore preserve behavior-relevant client options instead of aliasing external and internal clients.Compatibility
The intentional behavior changes are limited to client-cache identity and local metadata validation at corrected current/remote boundaries. Cross-connection operations now reach their configured backend; Azure Storage case variants now receive current-app validation. External and internal modes no longer share a cached client, preventing creation order from changing validation behavior. Exact-case provider semantics, the explicit external-client opt-out, replay, and deregistered listener drain behavior remain unchanged.
Tests
TDD RED evidence on
net8.0before production changes:DurableClientBaseTests: 8 expected failures covering cross-connection missing/disabled orchestrator start, restart, entity signal, and Azure Storage case-only matching.Accepted, observedBadRequest.InvalidArgumentlocal rejection.GREEN results:
DurableClientBaseTests: 50/50 passed onnet8.0; 50/50 passed onnet10.0.DurableClientBaseTests,DisabledFunctionDispatchTests,HttpApiHandlerTests,LocalGrpcListenerTests): 187/187 passed onnet8.0; 187/187 passed onnet10.0.git -c core.whitespace=cr-at-eol diff --check: passed.Automated Azure Storage E2E
CurrentAppDetectionTestsruns the real FunctionsV2 Durable extension and Azure Storage provider against two isolated Azurite processes:ITestHoston a second Azurite backend. The source-host client dispatches to the target, the orchestration completes there, and repeated source-backend reads remain absent.FunctionsV2E2Ejob starts independent Azurite data stores on ports10000-10002and11000-11002and probes all six service ports.SecondaryStorageis strictly a second localhost Azurite process (127.0.0.1). Its account value is Microsoft’s documented, well-known publicdevstoreaccount1emulator credential. It is not a live Azure Storage credential and cannot authenticate to an Azure Storage account.Regression proof:
334c7dd9aff4e6196421f2ae6e80651ee27450a7: both new tests fail behaviorally. The case-only client accepts and persists the disabled instance asPending; the cross-account client is rejected by source metadata becauseTargetOnlyOrchestratoris not locally registered.net8.0and 2/2 passed onnet10.0.Hosted external-client cache regression (#1926)
Commit
b31f039addsAzureStorage_HostedClientCache_PreservesExternalClientModeto the existing FunctionsV2 E2E suite. It uses real indexed internal/external client bindings, a client-only source host, and a target-only orchestrator.Behavioral RED with the hosted cache fix removed: both orders fail, respectively with the original
No orchestrator functions are currently registered!exception and with an internal start incorrectly accepted. GREEN with the existing PR cache fix: the new theory passed 2/2 onnet8.0and 2/2 onnet10.0, including a fresh publication-worktree run. The containing E2E class passed 4/4 on each TFM, and nearby external-client controls passed 3/3 on each TFM during implementation validation.This commit adds only regression tests and fixture functions; no duplicate production fix is introduced. The broader #1926 investigation also exercised shared HTTP/gRPC behavior, but this automated regression specifically covers hosted client bindings and does not claim full isolated-worker-process E2E coverage.
Supplemental real Azure validation
A manual A/B validation deployed the exact base and production-fix builds to isolated Windows Consumption Function Apps backed by two real Azure Storage accounts. It reproduced the base behavior and verified the PR behavior for direct Durable clients and built-in Durable HTTP routes, including start, restart, cross-account entity signaling, account-specific persistence, runtime logs, and App Insights traces. This supplemental run covered Azure Storage only; it did not claim live gRPC or Durable Task Scheduler coverage. All temporary Azure resources were deleted after preserving non-secret evidence.
Principal-level reviews found no remaining critical or important findings after adding the second Azurite setup to every FunctionsV2 E2E CI surface.
Supersedes #3527, which was opened from a fork and could not receive the upstream repository secrets required by all CI workflows.