From 3cd92661385c0b3bed8c0ede513bc7f09d0424e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 20:58:01 +0000 Subject: [PATCH 1/5] Initial plan From 85b5f4d209fca9c2fc198996e5669ad2d62d9665 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:03:38 +0000 Subject: [PATCH 2/5] Fix SQLite web interface by passing database file path as container argument Co-authored-by: hammar <68027+hammar@users.noreply.github.com> --- LocalAgent.AppHost/Program.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/LocalAgent.AppHost/Program.cs b/LocalAgent.AppHost/Program.cs index f5e06df..f9a1816 100644 --- a/LocalAgent.AppHost/Program.cs +++ b/LocalAgent.AppHost/Program.cs @@ -1,8 +1,26 @@ using CommunityToolkit.Aspire.Hosting; +using Aspire.Hosting.ApplicationModel; var builder = DistributedApplication.CreateBuilder(args); -var sqlite = builder.AddSqlite("sqlite").WithSqliteWeb(); +var sqliteBuilder = builder.AddSqlite("sqlite"); +var sqliteResource = sqliteBuilder.Resource; + +var sqlite = sqliteBuilder.WithSqliteWeb(containerBuilder => +{ + // Fix for Windows: sqlite-web expects the database file path as a command-line argument + // The database directory is mounted to /data, so we need to pass /data/{filename} + // Using reflection to access internal DatabaseFileName property + var databaseFileNameProperty = sqliteResource.GetType().GetProperty("DatabaseFileName", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var databaseFileName = databaseFileNameProperty?.GetValue(sqliteResource) as string; + + if (!string.IsNullOrEmpty(databaseFileName)) + { + var dbPath = $"/data/{databaseFileName}"; + containerBuilder.WithArgs(dbPath); + } +}); var llama32 = builder.AddOllama("ollama") .WithDataVolume() From aba69f58538b3eb1bd953f5f5ae7b19752d11f00 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:07:10 +0000 Subject: [PATCH 3/5] Add error handling for SQLite web database path configuration Co-authored-by: hammar <68027+hammar@users.noreply.github.com> --- LocalAgent.AppHost/Program.cs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/LocalAgent.AppHost/Program.cs b/LocalAgent.AppHost/Program.cs index f9a1816..e015de6 100644 --- a/LocalAgent.AppHost/Program.cs +++ b/LocalAgent.AppHost/Program.cs @@ -11,14 +11,33 @@ // Fix for Windows: sqlite-web expects the database file path as a command-line argument // The database directory is mounted to /data, so we need to pass /data/{filename} // Using reflection to access internal DatabaseFileName property - var databaseFileNameProperty = sqliteResource.GetType().GetProperty("DatabaseFileName", - System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); - var databaseFileName = databaseFileNameProperty?.GetValue(sqliteResource) as string; - - if (!string.IsNullOrEmpty(databaseFileName)) + try { - var dbPath = $"/data/{databaseFileName}"; - containerBuilder.WithArgs(dbPath); + var databaseFileNameProperty = sqliteResource.GetType().GetProperty("DatabaseFileName", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + + if (databaseFileNameProperty == null) + { + throw new InvalidOperationException( + "Unable to access DatabaseFileName property. The CommunityToolkit.Aspire.Hosting.SQLite library may have changed."); + } + + var databaseFileName = databaseFileNameProperty.GetValue(sqliteResource) as string; + + if (!string.IsNullOrEmpty(databaseFileName)) + { + var dbPath = $"/data/{databaseFileName}"; + containerBuilder.WithArgs(dbPath); + } + else + { + throw new InvalidOperationException("Database filename is null or empty."); + } + } + catch (Exception ex) + { + throw new InvalidOperationException( + $"Failed to configure SQLite Web container with database file path: {ex.Message}", ex); } }); From 67f6af48aebb94d9faaf9766b3af2d8c375850aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:08:19 +0000 Subject: [PATCH 4/5] Improve error handling with specific exceptions and actionable messages Co-authored-by: hammar <68027+hammar@users.noreply.github.com> --- LocalAgent.AppHost/Program.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/LocalAgent.AppHost/Program.cs b/LocalAgent.AppHost/Program.cs index e015de6..4184954 100644 --- a/LocalAgent.AppHost/Program.cs +++ b/LocalAgent.AppHost/Program.cs @@ -10,7 +10,9 @@ { // Fix for Windows: sqlite-web expects the database file path as a command-line argument // The database directory is mounted to /data, so we need to pass /data/{filename} - // Using reflection to access internal DatabaseFileName property + // + // Note: Using reflection to access internal DatabaseFileName property because it's not exposed publicly. + // If this breaks after a library update, check if DatabaseFileName has been made public or renamed. try { var databaseFileNameProperty = sqliteResource.GetType().GetProperty("DatabaseFileName", @@ -19,7 +21,10 @@ if (databaseFileNameProperty == null) { throw new InvalidOperationException( - "Unable to access DatabaseFileName property. The CommunityToolkit.Aspire.Hosting.SQLite library may have changed."); + "Unable to access DatabaseFileName property on SqliteResource. " + + "The CommunityToolkit.Aspire.Hosting.SQLite library structure may have changed. " + + "Please check the library version and update this code accordingly, or file an issue at " + + "https://github.com/CommunityToolkit/Aspire/issues"); } var databaseFileName = databaseFileNameProperty.GetValue(sqliteResource) as string; @@ -31,13 +36,25 @@ } else { - throw new InvalidOperationException("Database filename is null or empty."); + throw new InvalidOperationException( + "Database filename is null or empty. Ensure AddSqlite() is called with valid parameters."); } } + catch (InvalidOperationException) + { + // Re-throw our specific exceptions + throw; + } + catch (System.Reflection.TargetException ex) + { + throw new InvalidOperationException( + $"Failed to get DatabaseFileName property value: {ex.Message}", ex); + } catch (Exception ex) { throw new InvalidOperationException( - $"Failed to configure SQLite Web container with database file path: {ex.Message}", ex); + $"Unexpected error while configuring SQLite Web container: {ex.Message}. " + + $"This may indicate a compatibility issue with CommunityToolkit.Aspire.Hosting.SQLite.", ex); } }); From 407ce27ba6a554d43c1b7c50cfa90c8af4de4deb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:30:05 +0000 Subject: [PATCH 5/5] Simplify fix by updating CommunityToolkit.Aspire packages to 13.1.1 Co-authored-by: hammar <68027+hammar@users.noreply.github.com> --- LocalAgent.AppHost/LocalAgent.AppHost.csproj | 4 +- LocalAgent.AppHost/Program.cs | 56 +------------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/LocalAgent.AppHost/LocalAgent.AppHost.csproj b/LocalAgent.AppHost/LocalAgent.AppHost.csproj index 6a17f06..a15de55 100644 --- a/LocalAgent.AppHost/LocalAgent.AppHost.csproj +++ b/LocalAgent.AppHost/LocalAgent.AppHost.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/LocalAgent.AppHost/Program.cs b/LocalAgent.AppHost/Program.cs index 4184954..f5e06df 100644 --- a/LocalAgent.AppHost/Program.cs +++ b/LocalAgent.AppHost/Program.cs @@ -1,62 +1,8 @@ using CommunityToolkit.Aspire.Hosting; -using Aspire.Hosting.ApplicationModel; var builder = DistributedApplication.CreateBuilder(args); -var sqliteBuilder = builder.AddSqlite("sqlite"); -var sqliteResource = sqliteBuilder.Resource; - -var sqlite = sqliteBuilder.WithSqliteWeb(containerBuilder => -{ - // Fix for Windows: sqlite-web expects the database file path as a command-line argument - // The database directory is mounted to /data, so we need to pass /data/{filename} - // - // Note: Using reflection to access internal DatabaseFileName property because it's not exposed publicly. - // If this breaks after a library update, check if DatabaseFileName has been made public or renamed. - try - { - var databaseFileNameProperty = sqliteResource.GetType().GetProperty("DatabaseFileName", - System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); - - if (databaseFileNameProperty == null) - { - throw new InvalidOperationException( - "Unable to access DatabaseFileName property on SqliteResource. " + - "The CommunityToolkit.Aspire.Hosting.SQLite library structure may have changed. " + - "Please check the library version and update this code accordingly, or file an issue at " + - "https://github.com/CommunityToolkit/Aspire/issues"); - } - - var databaseFileName = databaseFileNameProperty.GetValue(sqliteResource) as string; - - if (!string.IsNullOrEmpty(databaseFileName)) - { - var dbPath = $"/data/{databaseFileName}"; - containerBuilder.WithArgs(dbPath); - } - else - { - throw new InvalidOperationException( - "Database filename is null or empty. Ensure AddSqlite() is called with valid parameters."); - } - } - catch (InvalidOperationException) - { - // Re-throw our specific exceptions - throw; - } - catch (System.Reflection.TargetException ex) - { - throw new InvalidOperationException( - $"Failed to get DatabaseFileName property value: {ex.Message}", ex); - } - catch (Exception ex) - { - throw new InvalidOperationException( - $"Unexpected error while configuring SQLite Web container: {ex.Message}. " + - $"This may indicate a compatibility issue with CommunityToolkit.Aspire.Hosting.SQLite.", ex); - } -}); +var sqlite = builder.AddSqlite("sqlite").WithSqliteWeb(); var llama32 = builder.AddOllama("ollama") .WithDataVolume()