Skip to content

Multiple bugs: empty input, panic on missing model, argument parsing #90

@noahgift

Description

@noahgift

Bugs Found via Testing

1. Empty/whitespace input returns suggestion instead of nothing

$ aprender-shell suggest ""
git status	1.000

$ aprender-shell suggest "   "
git status	1.000

Expected: No output for empty/whitespace-only input

Impact: Widget shows suggestions when user hasn't typed anything


2. Missing model file causes panic instead of graceful error

$ aprender-shell suggest "git " --model /nonexistent.bin
thread 'main' panicked at src/main.rs:424:46:
Failed to load model: Custom { kind: Other, error: "I/O error: No such file or directory (os error 2)" }

Expected: Clean error message with exit code 1, not panic

Fix:

let model = Model::load(&model_path).unwrap_or_else(|e| {
    eprintln!("Error: Could not load model '{}': {}", model_path.display(), e);
    std::process::exit(1);
});

3. Double-dash prefix causes argument parsing error

$ aprender-shell suggest "--"
error: the following required arguments were not provided:
  <PREFIX>

Cause: -- is interpreted as end-of-options separator

Fix: Use -- before the prefix argument in the CLI definition, or require:

$ aprender-shell suggest -- "--help"  # This should work

4. Export creates binary file but suggests .json extension

$ aprender-shell export /tmp/model.json
✅ Model exported to: /tmp/model.json

$ file /tmp/model.json
/tmp/model.json: data   # Not JSON!

Expected: Either export actual JSON, or use .bin/.aprn extension in examples


5. Null byte in input not sanitized

$ aprender-shell suggest $'git \x00status'
git status	1.000

Impact: Potential security issue with shell injection if suggestion is used unsafely


Environment

  • aprender-shell 0.1.0
  • Linux x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions