Skip to content

Commit 2dae947

Browse files
fixes for logging codql warning in webapiendpoints.cs file
1 parent 1a7855d commit 2dae947

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

App/kernel-memory/service/Service.AspNetCore/WebAPIEndpoints.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async Task<IResult> (
146146
ILogger<KernelMemoryWebAPI> log,
147147
CancellationToken cancellationToken) =>
148148
{
149-
log.LogTrace("New delete document HTTP request, index '{0}'", index);
149+
log.LogTrace("New delete document HTTP request, index {Index}", index?.Replace("\r", string.Empty).Replace("\n", string.Empty));
150150
await service.DeleteIndexAsync(index: index, cancellationToken)
151151
.ConfigureAwait(false);
152152
// There's no API to check the index deletion progress, so the URL is empty
@@ -180,7 +180,7 @@ async Task<IResult> (
180180
ILogger<KernelMemoryWebAPI> log,
181181
CancellationToken cancellationToken) =>
182182
{
183-
log.LogTrace("New delete document HTTP request, index '{0}'", index);
183+
log.LogTrace("New delete document HTTP request, index {Index}", index?.Replace("\r", string.Empty).Replace("\n", string.Empty));
184184
await service.DeleteDocumentAsync(documentId: documentId, index: index, cancellationToken)
185185
.ConfigureAwait(false);
186186
var url = Constants.HttpUploadStatusEndpointWithParams
@@ -217,7 +217,7 @@ async Task<IResult> (
217217
// Allow internal classes to access custom arguments via IContextProvider
218218
contextProvider.InitContextArgs(query.ContextArguments);
219219

220-
log.LogTrace("New search request, index '{0}', minRelevance {1}", query.Index, query.MinRelevance);
220+
log.LogTrace("New search request, index {Index}, minRelevance {MinRelevance}", query.Index?.Replace("\r", string.Empty).Replace("\n", string.Empty), query.MinRelevance);
221221
MemoryAnswer answer = await service.AskAsync(
222222
question: query.Question,
223223
index: query.Index,
@@ -252,7 +252,7 @@ async Task<IResult> (
252252
// Allow internal classes to access custom arguments via IContextProvider
253253
contextProvider.InitContextArgs(query.ContextArguments);
254254

255-
log.LogTrace("New search HTTP request, index '{0}', minRelevance {1}", query.Index, query.MinRelevance);
255+
log.LogTrace("New search HTTP request, index {Index}, minRelevance {MinRelevance}", query.Index?.Replace("\r", string.Empty).Replace("\n", string.Empty), query.MinRelevance);
256256
SearchResult answer = await service.SearchAsync(
257257
query: query.Query,
258258
index: query.Index,
@@ -338,7 +338,7 @@ public static void AddGetDownloadEndpoint(this IEndpointRouteBuilder builder, st
338338
string.IsNullOrWhiteSpace(filename));
339339
var errMsg = "Missing required parameter";
340340

341-
log.LogTrace("New download file HTTP request, index {0}, documentId {1}, fileName {3}", index, documentId, filename);
341+
log.LogTrace("New download file HTTP request, index {Index}, documentId {DocumentId}, fileName {FileName}", index?.Replace("\r", string.Empty).Replace("\n", string.Empty), documentId?.Replace("\r", string.Empty).Replace("\n", string.Empty), filename?.Replace("\r", string.Empty).Replace("\n", string.Empty));
342342

343343
if (!isValid)
344344
{
@@ -362,7 +362,7 @@ public static void AddGetDownloadEndpoint(this IEndpointRouteBuilder builder, st
362362
return Results.Problem(title: "File not found", statusCode: 404);
363363
}
364364

365-
log.LogTrace("Downloading file '{0}', size '{1}', type '{2}'", filename, file.FileSize, file.FileType);
365+
log.LogTrace("Downloading file {FileName}, size {FileSize}, type {FileType}", filename?.Replace("\r", string.Empty).Replace("\n", string.Empty), file.FileSize, file.FileType?.Replace("\r", string.Empty).Replace("\n", string.Empty));
366366
Stream resultingFileStream = await file.GetStreamAsync().WaitAsync(cancellationToken).ConfigureAwait(false);
367367
var response = Results.Stream(
368368
resultingFileStream,

0 commit comments

Comments
 (0)