Skip to content

Conversation

@DFanso
Copy link
Owner

@DFanso DFanso commented Oct 9, 2025

Description

Improve error handling for config loading

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please describe):

Related Issue

Fixes #108

Changes Made

  • Updates unmarshal errors in store functions to handle
  • old config formats, providing user instructions to
  • delete and re-run setup for better usability.

Testing

  • Tested with Gemini API
  • Tested with Grok API
  • Tested on Windows
  • Tested on Linux
  • Tested on macOS
  • Added/updated tests (if applicable)

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have tested this in a real Git repository
  • I have read the CONTRIBUTING.md guidelines

Screenshots (if applicable)

Additional Notes


For Hacktoberfest Participants

  • This PR is submitted as part of Hacktoberfest 2025

Thank you for your contribution! 🎉

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages when reading stored configuration. Instead of generic JSON errors, users now receive clear guidance that the config may be in an old format and instructions to delete it and re-run setup.
    • This clearer messaging appears during actions like saving settings, listing models, changing the default model, deleting models, and updating API keys.
    • No changes to commands or workflows beyond clearer error feedback.

- Updates unmarshal errors in store functions to handle
- old config formats, providing user instructions to
- delete and re-run setup for better usability.
@DFanso DFanso self-assigned this Oct 9, 2025
@DFanso DFanso added bug Something isn't working hacktoberfest Eligible for Hacktoberfest hacktoberfest-accepted Approved Hacktoberfest contribution go Pull requests that update go code labels Oct 9, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The change updates error handling in cmd/cli/store/store.go by wrapping JSON unmarshal failures with a specific message about outdated config format and remediation steps. A comment header was slightly reformatted. No method signatures or primary logic paths were altered.

Changes

Cohort / File(s) Summary
Store error handling updates
cmd/cli/store/store.go
Replaced bare json.Unmarshal error returns with a wrapped, user-facing error message in Save, DefaultLLMKey, ListSavedModels, ChangeDefault, DeleteModel, and UpdateAPIKey when data length > 2 and unmarshal fails; minor comment format tweak to KeyringInit header.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User as CLI User
    participant CLI as CLI Command
    participant Store as Store (store.go)
    participant Config as Config File/Keyring

    User->>CLI: Run LLM setup / model ops
    CLI->>Store: Read/Write models/config
    Store->>Config: Load JSON data
    Config-->>Store: bytes

    alt JSON parse success
        Store-->>CLI: Proceed with operation
        CLI-->>User: Success output
    else JSON parse error (data length > 2)
        note over Store: New behavior: wrap error<br/>with guidance to delete config<br/>and re-run setup (old format hint)
        Store-->>CLI: Wrapped, user-facing error
        CLI-->>User: Display remediation message
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled bytes in a config glade,
Found crunchy braces, slightly mislaid—
“Old format,” I thumped, “don’t dismay! 🥕”
Delete, re-run, and hop your way.
Now errors speak with clearer cheer,
The meadow’s paths are crystal here.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70ecc8c and 9571b69.

📒 Files selected for processing (1)
  • cmd/cli/store/store.go (7 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@DFanso DFanso merged commit 525f493 into main Oct 9, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code hacktoberfest Eligible for Hacktoberfest hacktoberfest-accepted Approved Hacktoberfest contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] LLM Setup command not working anymore

2 participants