refactor: remove operating agents from variables#1484
Conversation
| } | ||
|
|
||
| async fn set_operating_agent(&self, agent_id: AgentId) -> anyhow::Result<()> { | ||
| let mut config = self.services.read_app_config().await.unwrap_or_default(); |
There was a problem hiding this comment.
There appears to be inconsistent error handling between the two methods. In get_operating_agent(), errors from read_app_config() are properly propagated using the ? operator, while in set_operating_agent(), errors are silently converted to a default value with unwrap_or_default().
This creates a potential issue where read operations might fail with proper errors, but write operations would silently proceed with a default configuration even when the underlying storage system is failing.
Consider using consistent error handling in both methods:
let mut config = self.services.read_app_config().await?;This ensures that storage failures are handled consistently across both operations.
| let mut config = self.services.read_app_config().await.unwrap_or_default(); | |
| let mut config = self.services.read_app_config().await?; |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
|
|
||
| self.command.register_all(&base_workflow); | ||
| self.state = UIState::new(self.api.environment(), base_workflow).provider(provider); | ||
| let operating_agent = self.api.get_operating_agent().await.unwrap_or(None); |
There was a problem hiding this comment.
There appears to be an error in the error handling pattern here. The expression self.api.get_operating_agent().await.unwrap_or(None) is problematic because unwrap_or(None) is being applied to a Result<Option<AgentId>, Error>, not an Option.
This will panic if the API call returns an Err, rather than handling the error gracefully. Consider one of these alternatives:
// Option 1: Use unwrap_or_default() which works on Result<Option<T>, E>
self.api.get_operating_agent().await.unwrap_or_default()
// Option 2: Proper error handling with ? operator
let operating_agent = self.api.get_operating_agent().await?;The second approach would require propagating the error up the call chain.
| let operating_agent = self.api.get_operating_agent().await.unwrap_or(None); | |
| let operating_agent = self.api.get_operating_agent().await.unwrap_or_default(); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
…d implementations
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
No description provided.