Skip to content

Commit

Permalink
Rollback of Microsoft.Extensions.Http patch and extended BridgeReques…
Browse files Browse the repository at this point in the history
…tFailedException (#447)

#444
Rollback of Microsoft.Extensions.Http patch from 7.0.0 back to the original 6.0.2-mauipre.1.22102.15 which is the final patch change which might be the cause of failures.

BridgeRequestFailedException have been extended to be able to set message and inner exception as these now are just empty execeptions which makes debugging failure harder.

Co-authored-by: Jon Kjetil Øye <[email protected]>
  • Loading branch information
jonkjetiloye and Jon Kjetil Øye authored Aug 14, 2023
1 parent 8729eda commit 7af490d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Functions/Altinn.Platform.Authorization.Functions.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
Expand All @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.1.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="Altinn.Common.AccessTokenClient" Version="1.1.3" />
</ItemGroup>
Expand Down
37 changes: 37 additions & 0 deletions src/Functions/Exceptions/BridgeRequestFailedException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
using System;
using System.Runtime.Serialization;

namespace Altinn.Platform.Authorization.Functions.Exceptions;

/// <summary>
/// Generic exception used to trigger re-queueing of messages
/// </summary>
[Serializable]
public class BridgeRequestFailedException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="BridgeRequestFailedException"/> class.
/// </summary>
public BridgeRequestFailedException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BridgeRequestFailedException"/> class.
/// </summary>
/// <param name="message">Error message</param>
public BridgeRequestFailedException(string message)
: base(message)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BridgeRequestFailedException"/> class.
/// </summary>
/// <param name="message">Error message</param>
/// <param name="innerException">Inner exception</param>
public BridgeRequestFailedException(string message, Exception innerException)
: base(message, innerException)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BridgeRequestFailedException"/> class.
/// </summary>
/// <param name="info">Serialization info</param>
/// <param name="context">Context</param>
protected BridgeRequestFailedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
6 changes: 3 additions & 3 deletions src/Functions/Services/EventPusherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task PushEvents(DelegationChangeEventList delegationChangeEventList
if (delegationChangeEventList == null)
{
_logger.LogError("Received null instead of delegation change events. Failed to deserialize model?");
throw new BridgeRequestFailedException();
throw new BridgeRequestFailedException("Received null instead of delegation change events. Failed to deserialize model?");
}

delegationChangeEventList.DelegationChangeEvents ??= new List<DelegationChangeEvent>();
Expand Down Expand Up @@ -75,7 +75,7 @@ await response.Content.ReadAsStringAsync(),
GetChangeIdsForLog(delegationChangeEventList));

// Throw exception to ensure requeue of the event list
throw new BridgeRequestFailedException();
throw new BridgeRequestFailedException($"Bridge returned non-success. resultCode={response.StatusCode} reasonPhrase={response.ReasonPhrase} resultBody={await response.Content.ReadAsStringAsync()} numEventsSent={delegationChangeEventList.DelegationChangeEvents.Count} changeIds={GetChangeIdsForLog(delegationChangeEventList)}");
}

if (_logger.IsEnabled(LogLevel.Debug))
Expand All @@ -99,7 +99,7 @@ await response.Content.ReadAsStringAsync(),
delegationChangeEventList?.DelegationChangeEvents?.Count,
GetChangeIdsForLog(delegationChangeEventList));

throw new BridgeRequestFailedException();
throw new BridgeRequestFailedException($"Exception thrown while attempting to post delegation events to Bridge. exception={ex.GetType().Name} message={ex.Message} numEventsSent={delegationChangeEventList?.DelegationChangeEvents?.Count} changeIds={GetChangeIdsForLog(delegationChangeEventList)}", ex);
}
}

Expand Down

0 comments on commit 7af490d

Please sign in to comment.