Skip to content

Commit 239b986

Browse files
committed
Fix FTSSampleProject JSON value converter and BlogIndexer error handling
Add EF ValueConverter for FTSSampleProject.Files so List<string> correctly round-trips with the JSON text stored in the FTS5 column. Replace catch-and-rethrow in BlogIndexer with continue-with-warning so a single failed blog post doesn't abort the entire indexing run.
1 parent 3c5aeb2 commit 239b986

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

server/src/Docs.Indexer/Indexers/BlogIndexer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public async Task IndexAsync()
5050
}
5151
catch (Exception ex)
5252
{
53-
Console.WriteLine($" Error indexing {item.Title}: {ex.Message}");
54-
throw;
53+
Console.WriteLine($" Warning: Failed to index '{item.Title}': {ex.Message}");
5554
}
5655
}
5756

server/src/Docs.Mcp/Database/McpDb.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// See LICENSE in the project root for license information.
33

4+
using System.Text.Json;
45
using Microsoft.EntityFrameworkCore;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
57

68
namespace Docs.Mcp.Database;
79

@@ -61,6 +63,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
6163
// but we still need to configure the entities for querying
6264
modelBuilder.Entity<FTSDocsArticle>().HasNoKey();
6365
modelBuilder.Entity<FTSBlogArticle>().HasNoKey();
64-
modelBuilder.Entity<FTSSampleProject>().HasNoKey();
66+
modelBuilder.Entity<FTSSampleProject>(entity =>
67+
{
68+
entity.HasNoKey();
69+
70+
// FTS5 stores Files as a JSON text column — convert to/from List<string>
71+
entity.Property(e => e.Files).HasConversion(
72+
new ValueConverter<List<string>, string>(
73+
v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
74+
v => JsonSerializer.Deserialize<List<string>>(v, JsonSerializerOptions.Default) ?? new List<string>()));
75+
});
6576
}
6677
}

0 commit comments

Comments
 (0)