Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri(settings.Host);
c.Timeout = TimeSpan.FromSeconds(5);
c.Timeout = TimeSpan.FromSeconds(settings.TimeoutSecond);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Invalid timeout crashes startup 🐞 Bug ⛯ Reliability

RegisterDI sets HttpClient.Timeout from MembaseSettings.TimeoutSecond without validating it; if
config provides 0 or a negative value, setting HttpClient.Timeout throws during DI setup and can
prevent the host from starting.
Agent Prompt
### Issue description
`MembasePlugin.RegisterDI` sets `HttpClient.Timeout` from `settings.TimeoutSecond` without validating the configured value. A non-positive value (e.g., `0`/`-1`) can throw during DI startup and prevent the application from starting.

### Issue Context
`MembaseSettings` is bound directly from configuration (`config.Bind("Membase", settings)`), so invalid values are possible.

### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs[18-34]
- src/Plugins/BotSharp.Plugin.Membase/Settings/MembaseSettings.cs[3-9]

### Suggested fix
- Clamp or default invalid values before calling `TimeSpan.FromSeconds(...)` and assigning `c.Timeout` (e.g., `var timeoutSeconds = settings.TimeoutSecond > 0 ? settings.TimeoutSecond : 10;`).
- Optionally add an upper bound guard as well.
- Alternatively migrate to the options pattern and add validation (`Validate(...)`) so invalid configuration fails fast with a clear message.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

});

services.AddScoped<IGraphDb, MembaseGraphDb>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public class MembaseSettings
public string Host { get; set; } = "localhost";
public string ProjectId { get; set; } = string.Empty;
public string ApiKey { get; set; } = string.Empty;
public int TimeoutSecond { get; set; } = 10;
}
Loading