Skip to content

Commit

Permalink
Stop retrying unsupported file types
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc committed Nov 18, 2024
1 parent c054276 commit 1ada50d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions service/Abstractions/Pipeline/MimeTypeException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft. All rights reserved.

using System;

namespace Microsoft.KernelMemory.Pipeline;

public class MimeTypeException : KernelMemoryException
{
/// <inheritdoc />
public MimeTypeException(bool? isTransient = null)
{
this.IsTransient = isTransient;
}

/// <inheritdoc />
public MimeTypeException(string message, bool? isTransient = null) : base(message)
{
this.IsTransient = isTransient;
}

/// <inheritdoc />
public MimeTypeException(string message, Exception? innerException, bool? isTransient = null) : base(message, innerException)
{
this.IsTransient = isTransient;
}
}
2 changes: 1 addition & 1 deletion service/Abstractions/Pipeline/MimeTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public string GetFileType(string filename)
return mimeType;
}

throw new NotSupportedException($"File type not supported: {filename}");
throw new MimeTypeException($"File type not supported: {filename}", isTransient: false);
}

public bool TryGetFileType(string filename, out string? mimeType)
Expand Down
2 changes: 1 addition & 1 deletion service/Core/Pipeline/BaseOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ private async Task UploadFormFilesAsync(DataPipeline pipeline, CancellationToken
{
mimeType = this._mimeTypeDetection.GetFileType(file.FileName);
}
catch (NotSupportedException)
catch (MimeTypeException)
{
this.Log.LogWarning("File type not supported, the ingestion pipeline might skip it");
}
Expand Down

0 comments on commit 1ada50d

Please sign in to comment.