Skip to content

Local commands without required arguments cause runtime panic #263

Open

Description

@Bewear777

Bug description

Executing a local Console command without its required argument causes NebulaGraph Console to panic and exit instead of displaying an argument validation error.

For example, entering :repeat in the interactive Console results in a runtime panic.

Your Environments (required)

How To Reproduce(required)

  1. Start NebulaGraph Console and connect to a server.
  2. Enter the following local command without an argument:
:repeat

Actual behavior

Console exits with a runtime panic:

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
main.isConsoleCmd(...)
    /usr1/nebula_console/main.go:216
main.loop(...)
    /usr1/nebula_console/main.go:345
main.main(...)
    /usr1/nebula_console/main.go:652

In isConsoleCmd(), the command is split into words, but the repeat case accesses words[1] without checking whether the argument exists.

The same unchecked access is present in the handlers for :sleep, :play, :csv, :dot, :profile, and :explain.

Entering only : can also cause an out-of-range access at words[0].

Expected behavior

  • Validate that required arguments are present before accessing command arguments.
  • Display a clear error message when an argument is missing.
  • Keep the interactive Console running so that the user can enter the next command.
  • Preserve the existing behavior of valid local commands.

Additional context

Issue #162 was closed as fixed by PR #236. However, PR #236 updates startup flag validation and replaces several log.Panicf() calls; it does not add argument-count checks to the interactive local command parser in isConsoleCmd().

This issue tracks the remaining local-command argument validation gap.

Related issue: #162

Related pull request: #236

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions