#1077·glance

Duplicate `len(args) == 2` branch makes `mountpoint:info` command unreachable

Author: RlucienCreated Sep 11, 2026Updated Sep 11, 2026
Labelsbug report

Summary

In parseCliOptions, there are two consecutive else if len(args) == 2 branches. The second one is dead code and can never be executed, which makes the mountpoint:info command effectively unusable — it always falls through to the first len(args) == 2 branch and returns unknown command.

Affected Code

} else if len(args) == 2 {
    if args[0] == "password:hash" {
        intent = cliIntentPasswordHash
    } else {
        return nil, unknownCommandErr
    }
} else if len(args) == 2 {                // ← unreachable: same condition as above
    if args[0] == "mountpoint:info" {
        intent = cliIntentMountpointInfo
    } else {
        return nil, unknownCommandErr
    }
} else {
    return nil, unknownCommandErr
}

Steps to reproduce:

  1. Build and run Glance.

  2. Execute:

glance mountpoint:info
  1. Observe the result.

Expected Behavior

The mountpoint:info command should be recognized and cliMountpointInfo should be invoked with the given path (as advertised in the usage output: unknown command: mountpoint:info).

Root Cause

The second else if len(args) == 2 has exactly the same condition as the first one. Since the first branch already matches whenever len(args) == 2, the second branch is unreachable dead code. As a result:

  • password:hash <pwd> works (handled by the first branch).
  • mountpoint:info <path> never reaches its handler, because the first branch's else returns unknownCommandErr first.

Suggested Fix

Merge the two branches into a single len(args) == 2 block:

} else if len(args) == 2 {
    if args[0] == "password:hash" {
        intent = cliIntentPasswordHash
    } else if args[0] == "mountpoint:info" {
        intent = cliIntentMountpointInfo
    } else {
        return nil, unknownCommandErr
    }
} else {
    return nil, unknownCommandErr
}

Impact

  • The mountpoint:info command documented in the usage/help text is completely non-functional.
  • Any user relying on this command gets a misleading "unknown command" error instead of the intended output.

Additional Notes

  • Worth adding a small test covering argument parsing for each documented command to catch this kind of unreachable-branch regression in the future.
  • I'm happy to open a PR with the fix if that would be helpful.