Skip to content

feat(interp): improve error messages for blocked and unknown commands#182

Open
julesmcrt wants to merge 1 commit intojules.macret/Q/help-add-allowed_commandsfrom
jules.macret/Q/improve-error-messages
Open

feat(interp): improve error messages for blocked and unknown commands#182
julesmcrt wants to merge 1 commit intojules.macret/Q/help-add-allowed_commandsfrom
jules.macret/Q/improve-error-messages

Conversation

@julesmcrt
Copy link
Copy Markdown
Collaborator

Summary

  • All error messages now prefixed with rshell: to clearly identify the source shell (follows the bash: cmd: error convention)
  • "Command not allowed" (policy block) and "unknown command" (doesn't exist) use distinct wording so LLMs and users can immediately tell the difference
  • A contextual Run 'help' to see allowed/available commands. hint is appended only when help is in the allowed commands list — avoids suggesting a command that would itself be blocked

Before / After

1. Command not allowed — help IS in allowed list

./rshell --allowed-commands "rshell:echo,rshell:help,rshell:ls" -c 'cat'

Before:

cat: command not allowed

After:

rshell: cat: command not allowed
Run 'help' to see allowed commands.

2. Command not allowed — help NOT in allowed list

./rshell --allowed-commands "rshell:echo,rshell:ls" -c 'cat'

Before:

cat: command not allowed

After:

rshell: cat: command not allowed

No hint is shown because help itself is not allowed — suggesting it would produce a confusing follow-up error.

3. Unknown command — help IS in allowed list

./rshell --allowed-commands "rshell:echo,rshell:help,rshell:ls" -c 'foo'

Before:

foo: command not allowed

After:

rshell: foo: command not allowed
Run 'help' to see allowed commands.

Note: foo is not in the allowed list, so the allow check fires before the builtin lookup. The "unknown command" path is only reached when a command passes the allow check but isn't a known builtin (e.g., with --allow-all-commands).

4. Unknown command — help NOT in allowed list

./rshell --allowed-commands "rshell:echo,rshell:ls" -c 'foo'

Before:

foo: command not allowed

After:

rshell: foo: command not allowed

5. Unknown command with --allow-all-commands (the "unknown command" path)

./rshell --allow-all-commands -c 'foo'

Before:

foo: command not found

After:

rshell: foo: unknown command
Run 'help' to see available commands.

Design decisions

  • rshell: prefix — Follows the shell: cmd: error convention used by bash/zsh. Helps LLMs and log parsers identify which shell produced the error.
  • "command not allowed" vs "unknown command" — Distinct wording prevents confusion between "exists but blocked by policy" and "doesn't exist in this shell at all".
  • Conditional hint — The Run 'help' ... hint only appears when help is in the allowed commands set. This avoids a frustrating UX where following the hint produces another error (rshell: help: command not allowed). The check uses r.allowedCommands["help"] for the "not allowed" path, and a pre-computed helpAvailable bool captured at runner creation for the exec handler path.
  • No version in error messageshelp output already shows the rshell version (via feat(help): show version, command counts, and allowed/not-allowed builtins #181), keeping errors concise.

Depends on

Test plan

  • All 65 modified scenario + Go tests passing (go test ./... — 0 failures)
  • Manual verification of all 5 cases above
  • Conditional hint verified: appears only when help is allowed
  • make fmt clean

🤖 Generated with Claude Code

Prefix all error messages with "rshell:" to clearly identify the shell,
use distinct wording ("command not allowed" vs "unknown command") so
LLMs and users can tell policy blocks from missing commands, and
add a contextual hint pointing to 'help' when it is available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@julesmcrt julesmcrt changed the base branch from main to jules.macret/Q/help-add-allowed_commands April 14, 2026 15:21
@julesmcrt julesmcrt marked this pull request as ready for review April 14, 2026 15:21
@julesmcrt julesmcrt force-pushed the jules.macret/Q/help-add-allowed_commands branch from 4ee0b74 to cdc07cf Compare April 14, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants