add membase timeout in setting#1311
Conversation
Review Summary by QodoMake Membase HTTP client timeout configurable
WalkthroughsDescription• Add configurable timeout setting for Membase HTTP client • Replace hardcoded 5-second timeout with configurable value • Default timeout set to 10 seconds via settings Diagramflowchart LR
A["MembaseSettings"] -->|"TimeoutSecond property"| B["MembasePlugin"]
B -->|"uses configured timeout"| C["HttpClient configuration"]
D["Hardcoded 5 seconds"] -.->|"replaced by"| A
File Changes1. src/Plugins/BotSharp.Plugin.Membase/Settings/MembaseSettings.cs
|
Code Review by Qodo
1. Invalid timeout crashes startup
|
| { | ||
| c.BaseAddress = new Uri(settings.Host); | ||
| c.Timeout = TimeSpan.FromSeconds(5); | ||
| c.Timeout = TimeSpan.FromSeconds(settings.TimeoutSecond); |
There was a problem hiding this comment.
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
|
reviewed |
No description provided.