Skip to content

The targetModelId assignment uses the null-coalescing operator with template.Id as fallback, but there's no validation that targetModel is not null after the repository call. If GetByIdWithChildrenAsync returns null, this will cause a NullReferenceException when the model is accessed later. Add null check after line 99. #25

Description

@mmeents

The targetModelId assignment uses the null-coalescing operator with template.Id as fallback, but there's no validation that targetModel is not null after the repository call. If GetByIdWithChildrenAsync returns null, this will cause a NullReferenceException when the model is accessed later. Add null check after line 99.

        var targetModel = await _modelRepository.GetByIdWithChildrenAsync(targetModelId, maxDepth: 3, cancellationToken);
        if (targetModel == null)
        {
          outputs.Add($"Error executing template {template.Id}: target model {targetModelId} was not found.");
          return outputs;
        }

Originally posted by @Copilot in #24 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions