Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/core-api/Services/MycosoftIntegrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public async Task<HplSimulationResult> ProcessHplSimulationAsync(HplSimulationRe

simResponse.EnsureSuccessStatusCode();
var simResult = await simResponse.Content.ReadFromJsonAsync<MyceliumSimResult>(cancellationToken);
if (simResult == null)
{
throw new InvalidOperationException("Simulation service returned no result");
}

// Store results in MINDEX
await StoreSimulationResultAsync(simResult);
Expand Down
9 changes: 7 additions & 2 deletions src/ingestion/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@

services.AddSingleton(provider =>
{
var endpoint = configuration.GetConnectionString("EventGridConnectionString") ??
var endpoint = configuration.GetConnectionString("EventGridConnectionString") ??
configuration["EventGridConnectionString"];
var key = configuration["EventGridKey"] ?? "";
if (string.IsNullOrWhiteSpace(endpoint))
{
throw new InvalidOperationException("EventGrid connection string is not configured");
}

var key = configuration["EventGridKey"] ?? string.Empty;
return new EventGridPublisherClient(new Uri(endpoint), new AzureKeyCredential(key));
Comment on lines +41 to 42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Defaulting to an empty string for the EventGrid key may mask misconfiguration.

Constructing EventGridPublisherClient with an empty key may cause runtime authentication errors. Instead, throw an exception if the key is missing, as is done for the endpoint.

Suggested change
var key = configuration["EventGridKey"] ?? string.Empty;
return new EventGridPublisherClient(new Uri(endpoint), new AzureKeyCredential(key));
var key = configuration["EventGridKey"];
if (string.IsNullOrWhiteSpace(key))
{
throw new InvalidOperationException("EventGrid key is not configured");
}
return new EventGridPublisherClient(new Uri(endpoint), new AzureKeyCredential(key));

});

Expand Down
Loading