Uh oh!
There was an error while loading. Please reload this page.
Revert "Fix membase json" - #1394
Conversation
Uh oh!
There was an error while loading. Please reload this page.
PR Summary by QodoRevert Membase JSON handling changes and relax OpenAI settings validation
AI Description
Diagram
High-Level Assessment
Files changed (3) |
Code Review by Qodo
1. Null settings dereference |
| if (settings == null && string.IsNullOrEmpty(apiKey)) | ||
| { | ||
| throw new InvalidOperationException($"No LLM model settings found for '{provider}.{model}'. Register the model under LlmProviders (appsettings/user secrets) or pass an api key."); | ||
| } |
There was a problem hiding this comment.
1. Null settings dereference 🐞 Bug☼ Reliability
ProviderHelper.GetClient can now throw NullReferenceException when ILlmProviderService.GetSetting returns null and apiKey is null, because it still evaluates settings!.ApiKey. This regresses from a clear InvalidOperationException explaining how to configure the model/key.
Agent Prompt
### Issue description
`ProviderHelper.GetClient` no longer validates the case where both the configured model setting is missing and the caller did not provide an API key, leading to a `NullReferenceException` from `settings!.ApiKey`.
### Issue Context
`ILlmProviderService.GetSetting` explicitly returns null when provider/model settings are not found, and several OpenAI providers call `ProviderHelper.GetClient(..., apiKey: null, ...)`, making the null-settings path reachable.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.OpenAI/Providers/ProviderHelper.cs[8-15]
- src/Infrastructure/BotSharp.Core/Infrastructures/LlmProviderService.cs[77-95]
- src/Plugins/BotSharp.Plugin.OpenAI/Providers/Image/ImageCompletionProvider.Compose.cs[24-29]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| services.AddRefitClient<IMembaseApi>(new RefitSettings | ||
| { | ||
| CollectionFormat = CollectionFormat.Multi | ||
| }) |
There was a problem hiding this comment.
2. Unpinned membase json deserialization 🐞 Bug≡ Correctness
MembasePlugin no longer configures a specific Refit JSON content serializer, but graph construction relies on Dictionary<string, object?> values being JsonElement for node/edge objects. If Refit deserializes those object values into inferred CLR types (e.g., nested dictionaries) instead of JsonElement, GraphBuilder.Build will skip rows and can produce incomplete/empty graphs.
Agent Prompt
### Issue description
The Membase Refit client no longer pins JSON deserialization behavior. Downstream code expects `GraphQueryResult.Values` dictionaries to contain `JsonElement` objects for keys like `sourceNode`, `targetNode`, and `edge`.
### Issue Context
`MembaseGraphDb` passes `CypherQueryResponse.Data` straight through to `GraphQueryResult.Values`. `GraphBuilder.Build` uses `ObjectExtensions.TryGetValue<JsonElement>` and will `continue` (drop the row) when the value isn't a `JsonElement` (or already a `JsonElement`-deserializable `T`).
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs[21-39]
- src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs[41-55]
- src/Infrastructure/BotSharp.Abstraction/Graph/Utils/GraphBuilder.cs[18-26]
- src/Infrastructure/BotSharp.Abstraction/Utilities/ObjectExtensions.cs[76-105]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Reverts #1391