File tree Expand file tree Collapse file tree
live/Codebreaker.Live/Endpoints
ranking/Codebreaker.Ranking/Services Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Azure . Messaging . EventHubs . Consumer ;
22
3- using Microsoft . Extensions . Azure ;
4-
53using System . Runtime . CompilerServices ;
64
75namespace Codebreaker . Live . Endpoints ;
@@ -12,11 +10,16 @@ public async IAsyncEnumerable<GameSummary> SubscribeToGameCompletions(string gam
1210 {
1311 await foreach ( PartitionEvent ev in consumerClient . ReadEventsAsync ( cancellationToken ) )
1412 {
15- GameSummary gameSummary ;
13+ GameSummary ? gameSummary ;
1614 try
1715 {
1816 logger . ProcessingGameCompletionEvent ( ) ;
1917 gameSummary = ev . Data . EventBody . ToObjectFromJson < GameSummary > ( ) ;
18+ if ( gameSummary is null )
19+ {
20+ logger . GameSummaryIsNull ( ) ;
21+ continue ;
22+ }
2023 }
2124 catch ( Exception ex )
2225 {
Original file line number Diff line number Diff line change @@ -15,7 +15,13 @@ public async Task StartProcessingAsync(CancellationToken cancellationToken = def
1515 {
1616 logger . LogInformation ( "Processing event" ) ;
1717
18- GameSummary summary = args . Data . EventBody . ToObjectFromJson < GameSummary > ( ) ;
18+ GameSummary ? summary = args . Data . EventBody . ToObjectFromJson < GameSummary > ( ) ;
19+
20+ if ( summary is null )
21+ {
22+ logger . LogWarning ( "Game summary is empty after deserialization" ) ;
23+ return ;
24+ }
1925
2026 logger . LogInformation ( "Received game completion event for game {gameId}" , summary . Id ) ;
2127 using var context = await factory . CreateDbContextAsync ( cancellationToken ) ;
You can’t perform that action at this time.
0 commit comments