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)
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.
Originally posted by @Copilot in #24 (comment)