Skip to content

Commit

Permalink
added null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhaeger committed Jan 28, 2025
1 parent 066cd97 commit c272983
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Altinn.App.Api/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ public async Task<IActionResult> SetQueryParams(string org, string app)
.Where(item => item != null)
.ToList();

// Prepare the result grouped by dataModelName
var result = modelPrefill
.Select(entry =>
{
if (entry.PrefillConfiguration == null) // Check if PrefillConfiguration is null

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (macos-latest)

Dereference of a possibly null reference.

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (macos-latest)

Dereference of a possibly null reference.

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Static code analysis

Dereference of a possibly null reference.

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (ubuntu-latest)

Dereference of a possibly null reference.

Check failure on line 146 in src/Altinn.App.Api/Controllers/HomeController.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (ubuntu-latest)

Dereference of a possibly null reference.
{
return null;
}

var queryParamsConfig = entry.PrefillConfiguration["QueryParams"];
if (queryParamsConfig == null || queryParamsConfig.Type != JTokenType.Object)
{
Expand All @@ -165,10 +169,8 @@ public async Task<IActionResult> SetQueryParams(string org, string app)
.Where(entry => entry != null && entry.PrefillFields.Count > 0)
.ToList();

// Serialize the result to JSON
var resultJson = System.Text.Json.JsonSerializer.Serialize(result);

// Generate HTML to set sessionStorage
var htmlContent =
$@"
<!DOCTYPE html>
Expand Down

0 comments on commit c272983

Please sign in to comment.