Skip to content

[Code scan] Propagate toolchain argument parsing failures #7566

Description

@njzjz

This issue is a result of a Codex global repository scan.

install_abacus_toolchain_new.sh checks config_init and exits 0 on failure after printing help. Inside the config layer, argument parsing can return 1 for invalid options or malformed --package-version values, but these failures must propagate all the way back to the top-level script to stop installation and return a nonzero status.

Top-level failure path exits success:

main() {
local args=("$@")
# Initialize configuration with command line arguments
if ! config_init "${args[@]}"; then
show_help
exit 0
fi

Argument parser error examples:

# Validate we have at least one argument
if [[ -z "$package_version_args" ]]; then
report_error $LINENO "--package-version requires at least one package:version argument"
return 1
fi
# Process each package:version pair
local pair_count=0
for pair in $package_version_args; do
if [[ "$pair" =~ ^([a-zA-Z0-9_]+):(main|alt)$ ]]; then
local pkg="${BASH_REMATCH[1]}"
local ver="${BASH_REMATCH[2]}"
CONFIG_CACHE["PACKAGE_VERSION_${pkg^^}"]="$ver"
((pair_count++))
else
report_error $LINENO "Invalid package version format: '$pair'. Use format 'package:version' (e.g., openmpi:alt, openblas:main)"
return 1

Impact:

Invalid CLI input can be reported but still produce a successful command status, which is unsafe for CI and wrapper scripts.

Suggested fix:

Make config_init return nonzero whenever parsing or validation fails, and make the top-level script exit nonzero on that path. For example, use config_parse_arguments "$@" || return 1 and exit 1 after showing help for invalid input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions