fix: warn on config parse errors during auth login#311
Conversation
When `storage::load_config()` fails in the auth login path, add an `.inspect_err()` call that prints a warning to stderr before falling back to defaults. Previously, parse errors were silently swallowed, which could cause users with custom api_url/app_url settings to unknowingly authenticate against production. Closes #307 Co-Authored-By: Sachin Iyer <siyer@detail.dev>
Original prompt from Sachin
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Current Aviator status
This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.
See the real-time status of this PR on the
Aviator webapp.
Use the Aviator Chrome Extension
to see the status of your PR within GitHub.
|
| let config = storage::load_config() | ||
| .inspect_err(|e| { | ||
| let _ = Term::stderr().write_line(&format!( | ||
| "Warning: Config file has errors, using default settings: {e}" | ||
| )); | ||
| }) | ||
| .unwrap_or_default(); |
There was a problem hiding this comment.
📝 Info: Inconsistent config error handling across call sites
The PR adds a user-facing warning when load_config() fails in the Login handler, but the other call site in src/lib.rs:74 (create_client) propagates the error with ? instead. This means a corrupted config causes auth login to silently fall back to defaults (now with a warning), while auth status and all other commands using create_client() will hard-fail. This is intentional — login needs to work even with a broken config so the user can re-authenticate — but it's worth noting the asymmetry.
Was this helpful? React with 👍 or 👎 to provide feedback.
## Summary Patch release bump `0.2.5` → `0.2.6`. Includes fixes merged since v0.2.5: - `#313` serialize SHELL env var mutation in completions tests - `#312` validate `$SHELL` before extracting shell name in completions - `#311` warn on config parse errors during auth login - `#310` handle IPv6 bracketed hosts in `strip_ssh_port` Once merged, the `release.yml` workflow will automatically tag `v0.2.6`, build platform artifacts via `cargo-dist`, and publish a GitHub Release. Link to Devin session: https://app.devin.ai/sessions/02dfe916725247d6955ba0d4a49460df Requested by: @sachiniyer <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/usedetail/cli/pull/315" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review"> </picture> </a> <!-- devin-review-badge-end --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Release v0.2.6 to ship fixes for shell detection, SSH host parsing, and clearer auth warnings, plus more reliable completion tests. - **Bug Fixes** - Serialize `SHELL` env var mutation in completions tests to prevent flakiness. - Validate `$SHELL` before extracting the shell name in completions. - Warn on config parse errors during `auth login`. - Handle IPv6 bracketed hosts in `strip_ssh_port`. <sup>Written for commit db9999c. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/usedetail/cli/pull/315?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. --> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Sachin Iyer <siyer@detail.dev>
Summary
storage::load_config().unwrap_or_default()in theAuthCommands::Loginarm silently swallowed config parse errors, causing users with customapi_url/app_url(e.g. staging) to unknowingly authenticate against production.Added
.inspect_err()before.unwrap_or_default()to print a warning to stderr when parsing fails, while still falling back to defaults for bootstrap/recovery:Closes #307
Link to Devin session: https://app.devin.ai/sessions/c760784c0c454dd096c8def6f4406ec6
Requested by: @sachiniyer
Summary by cubic
Warn on config parse errors during auth login by printing to stderr before falling back to defaults. Prevents silent fallback that could make users with custom
api_url/app_urlauthenticate against production.Written for commit cc28dc7. Summary will update on new commits.