Skip to content

feat: add vault path validation in config #14

@LudoLoops

Description

@LudoLoops

Issue

The VaultPath configuration is not validated when loaded or set.

Problem

  • User might enter invalid paths (relative, non-existent, etc.)
  • Silent failures occur if path doesn't exist
  • No user feedback about bad configuration

Current Behavior

// In config.go - path accepted without validation
cfg.General.VaultPath = absPath  // No checks\!

Solution

Add validation function:

func validateVaultPath(path string) error {
    // Check if path is absolute
    if \!filepath.IsAbs(path) {
        return fmt.Errorf("vault path must be absolute, got: %s", path)
    }
    
    // Check if path exists
    if _, err := os.Stat(path); os.IsNotExist(err) {
        return fmt.Errorf("vault path does not exist: %s", path)
    }
    
    // Check if readable
    if err := os.Access(path, os.R_OK|os.W_OK); err \!= nil {
        return fmt.Errorf("vault path not readable/writable: %w", err)
    }
    
    return nil
}

Apply in LoadConfig() and on user input.

Benefits

  • Catch configuration errors early
  • Better user feedback
  • Prevent silent failures

Impact

🟢 Low - UX improvement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions