Skip to content

lib_cli.sh: handler= is not validated until dispatch time, not at command declaration #298

Description

@codeforester

Summary

A command's handler= attribute is checked as a syntactically legal Bash identifier when the command is declared, but whether that function actually exists is only checked with declare -F when base_cli_run dispatches to it (lib/bash/cli/lib_cli.sh:854-859).

Details

This means a typo'd handler name (e.g. handler=hanlde_status instead of handler=handle_status) passes declaration cleanly and only surfaces as a runtime failure the first time a user actually invokes that specific subcommand — far from where the mistake was made, and easy to miss in manual testing if a command is rarely exercised.

Impact

CLI authors get no early signal that a command is wired to a non-existent function; the failure mode is "command silently broken until someone runs it," discovered by an end user rather than at declare time or in CI.

Suggested fix

Add an optional eager validation pass (e.g. invoked from base_cli_model_init completion, or a dedicated base_cli_validate_model the author can call in tests/CI) that walks every declared command and confirms its handler resolves via declare -F before the CLI ever ships.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions