Stop the GL account-code check from being able to abort startup
The catch filter only matched DomainException/OperationCanceledException, so anything else escaped a hosted service and took the host down. One such path was mine: `"items": null` deserializes over the property initialiser, so `data.Items.Select(...)` would NullReferenceException straight past the filter. Fixed at both ends - the reader tolerates a null or absent items array, and the catch is now a deliberate catch-all that only lets a genuine host shutdown through. This is a diagnostic; a diagnostic that can core-dump the thing it diagnoses is worse than no diagnostic at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,9 +56,10 @@ public sealed class GeneralLedgerService : IGeneralLedgerService
|
||||
// `parentAccountId` is a field, not a nested `children` array).
|
||||
var response = await _client.SendAsync(HttpMethod.Get, "accounts", null, null, null, ct);
|
||||
var data = ParseSuccess<GlAccountListData>(response);
|
||||
return data.Items
|
||||
// `"items": null` deserializes over the property initialiser, so the null check is load-bearing.
|
||||
return (data.Items ?? [])
|
||||
.Where(a => a is not null && !string.IsNullOrWhiteSpace(a.AccountCode))
|
||||
.Select(a => a.AccountCode)
|
||||
.Where(c => !string.IsNullOrWhiteSpace(c))
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ public sealed class GeneralLedgerService : IGeneralLedgerService
|
||||
|
||||
private sealed class GlAccountListData
|
||||
{
|
||||
public List<GlAccountData> Items { get; set; } = [];
|
||||
public List<GlAccountData>? Items { get; set; }
|
||||
}
|
||||
|
||||
private sealed class GlAccountData
|
||||
|
||||
Reference in New Issue
Block a user