-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
design import and design export commands succeed silently even when given paths that don't exist or are not writable.
Steps to Reproduce
# Import from nonexistent file - should fail
ainative-code design import --file /nonexistent/file.json
# Exit code: 0 (success) - WRONG!
# Export to non-writable path - should fail
ainative-code design export --file /root/cannot/write/here.json
# Exit code: 0 (success) - WRONG!Expected Behavior
ainative-code design import --file /nonexistent/file.json
# Error: file not found: /nonexistent/file.json
ainative-code design export --file /root/cannot/write/here.json
# Error: permission denied: cannot write to /root/cannot/write/here.jsonActual Behavior
Both commands return exit code 0 without any error message, giving the false impression that the operation succeeded.
Impact
- Users think their tokens were imported when they weren't
- Data loss potential if users assume export succeeded
- Silent failures are hard to debug in scripts
Suggested Fix
Add file existence/permission checks before proceeding:
func validateInputFile(path string) error {
if _, err := os.Stat(path); os.IsNotExist(err) {
return fmt.Errorf("file not found: %s", path)
}
return nil
}
func validateOutputPath(path string) error {
dir := filepath.Dir(path)
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("cannot create directory: %w", err)
}
// Test write permission
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return fmt.Errorf("cannot write to %s: %w", path, err)
}
f.Close()
os.Remove(path)
return nil
}Environment
- Version: v0.1.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working