Skip to content

Improve configuration handling and error messages #399

Open
@bhouston

Description

@bhouston

Description

Based on the analysis of issue #397, there are several improvements that could be made to MyCoder's configuration handling to make it more user-friendly and robust:

Current Issues

  1. When a configuration file is not loaded correctly, MyCoder silently falls back to defaults without warning the user
  2. The error message about Anthropic API is confusing when the user has configured a different provider
  3. The ESM vs CommonJS format requirements are not clearly documented
  4. Environment variables for the default provider are checked even when a different provider is specified

Proposed Improvements

  1. Better Configuration Loading Feedback:

    • Log which configuration file was loaded and from where
    • Warn when no configuration file was found
    • Provide clear error messages for syntax or format errors in configuration files
  2. Provider-Specific Validation:

    • Only check for environment variables related to the configured provider
    • Add a validation step that verifies the required environment variables are present before attempting to use them
  3. Improved Error Messages:

    • When an API call fails, include information about which provider was being used
    • Provide clearer guidance on how to set up the required environment variables
    • Add a troubleshooting section to error messages
  4. Documentation Updates:

    • Clarify the naming and format requirements for configuration files
    • Add examples for different locations (project-level vs global)
    • Document Node.js version requirements for ESM support

Implementation Ideas

  1. Add a debug log in loadConfig() that shows which files were checked and which one was loaded
  2. Modify the provider factory to validate environment variables before attempting to create the provider
  3. Update error handling in API calls to include more context
  4. Add a configuration validation step that runs before executing commands

Related Issues

Priority

Medium - This would significantly improve the user experience, especially for new users setting up MyCoder for the first time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions