Repository navigation
Conversation
…03 and 504 AppAccessHandler and the other PEP callers get null from PDPAppSI when the call to the authorization decision endpoint fails, and the request then ends in 500 (data save) or 403 (opening or creating an instance), although the next request a moment later goes through. PdpRetryDelegatingHandler sends the request once more on HttpRequestException or a 502, 503 or 504 response. A decision request only asks a question, so sending it twice changes nothing. Cancellation and other status codes are not retried.
…response is disposed, and create the handler with a factory
…t no attempt is left running when SendAsync returns
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Author
|
Could someone approve the workflow runs and add the |
Bjarnisan
force-pushed
the
fix/retry-pdp-decision
branch
from
October 30, 2026 08:05
2ce3b0f to
79ef708
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the call to the authorization PDP fails at the network level, or the PDP answers 502, 503 or 504,
PDPAppSIreturns null and the user's request fails: a data save with 500, and opening or creating an instance with 403. Nothing retries the call, and the next request a moment later usually goes through. The issue has the numbers from our apps.PdpRetryDelegatingHandlersends the request once more in those cases. It is added to theAuthorizationApiClientregistration inAddAltinnAppServices, so it covers every call throughIPDP:AppAccessHandler,AuthorizationClient,InstancesControllerandStatelessDataController.HttpRequestExceptionand 502, 503 and 504 are retried, once and without delay. Other status codes, 500 and 429 included, pass through unchanged. A canceled request is not sent again, also when it is canceled after the first attempt failed.HttpClient.Timeoutcovers both attempts.MaskinportenDelegatingHandler, so the public API is unchanged and there is no new dependency. Each attempt gets its own HTTP client activity, and a retry logs one warning. Both attempts send the sametraceparent, sinceDiagnosticsHandleronly adds trace headers that are missing, so the PDP's telemetry links a retried call to the first attempt, in the same trace.This does not change what happens after two failures in a row: the request fails as before. In the TLS case the user still waits about 26 seconds before the second attempt. v9 has the same registration (
src/App/backend/src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.csin altinn-studio), and I can open a PR there too if you want this.Related Issue(s)
Verification
PdpRetryDelegatingHandlerTestshas 17 cases: a retry after 502, 503, 504 andHttpRequestExceptionwith the same body sent twice, the first response disposed, two failures in a row, no retry for 200, 400, 401, 403, 404 and 500, no retry when the request is canceled before or after the first attempt, and no attempt still running whenSendAsyncreturns.ServiceCollectionExtensionsTestsbuilds the app withAppBuilderand checks that anAuthorizationApiClientfrom DI gets the decision after one failed attempt. Removing the registration, the status code check, the retry afterHttpRequestException,response.Dispose()or the cancellation check, counting 500 as transient, catching every exception, or sending the retry without awaiting it each makes at least one test fail. Coverlet shows every changed line and branch insrccovered. Core and Api tests pass on net8.0 and net10.0, andCI=true dotnet build solutions/All.slngives no code warnings.Manual test in localtest with two of our apps and a small TCP proxy in front of the PDP that resets the connection, answers 503, or holds a request and then resets it, on demand. On Altinn.App 8.12.11 and on
main, one reset gave 500 on a data save, 403 when opening the instance and 403 when creating a new one, and one 503 gave 500 on a save. With this branch all four went through, and the log showed one "Request to PDP failed, retrying once" or "PDP returned 503, retrying once" per failure. Two resets in a row still gave 500, and the next save went through. With a save held for 6 seconds while a second client saved and submitted the instance, the held save got 409 after its retry, and the submitted data was unchanged.Documentation