Skip to content

Commit 90b2d4e

Browse files
committed
Improve guarding at EvaluateArtifact
1 parent a584d49 commit 90b2d4e

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/services/Elastic.Changelog/Evaluation/ChangelogArtifactEvaluationService.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,22 @@ public class ChangelogArtifactEvaluationService(
2727

2828
public async Task<bool> EvaluateArtifact(IDiagnosticsCollector collector, EvaluateArtifactArguments input, Cancel ctx)
2929
{
30-
if (!_fileSystem.File.Exists(input.MetadataPath))
31-
{
32-
_logger.LogInformation("Metadata file not found at {Path}, nothing to evaluate", input.MetadataPath);
33-
return true;
34-
}
35-
3630
ChangelogArtifactMetadata? metadata;
3731
try
3832
{
3933
var artifactMetadataJson = await _fileSystem.File.ReadAllTextAsync(input.MetadataPath, ctx);
4034
metadata = JsonSerializer.Deserialize(artifactMetadataJson, ChangelogArtifactMetadataJsonContext.Default.ChangelogArtifactMetadata);
4135
}
36+
catch (FileNotFoundException)
37+
{
38+
_logger.LogInformation("Metadata file not found at {Path}, nothing to evaluate", input.MetadataPath);
39+
return true;
40+
}
41+
catch (DirectoryNotFoundException)
42+
{
43+
_logger.LogInformation("Metadata file not found at {Path}, nothing to evaluate", input.MetadataPath);
44+
return true;
45+
}
4246
catch (IOException ex)
4347
{
4448
collector.EmitError(input.MetadataPath, $"Failed to read artifact metadata: {ex.Message}");

0 commit comments

Comments
 (0)