HBASE-28660 list_namespace not working after an incorrect user input#7931
HBASE-28660 list_namespace not working after an incorrect user input#7931arvindKandpal-ksolves wants to merge 2 commits intoapache:masterfrom
Conversation
Fixes an issue where mistakenly parsed local variables shadow HBase shell commands. Added cleanup logic in IRB eval loop to replace polluted bindings, along with a warning message for the user. Added relevant test cases in general_test_cluster.rb.
vaijosh
left a comment
There was a problem hiding this comment.
LGTM.
I have tested this features and verified that it works fine.
There was a problem hiding this comment.
Pull request overview
This PR addresses HBASE-28660 by preventing HBase shell commands (e.g., list, list_namespace) from being shadowed by local variables created during IRB evaluation, and adds a regression test to ensure reserved command names cannot persist as locals.
Changes:
- Add an
ensureblock inIRB::HIRB#eval_inputto detect and remove local variables that conflict with HBase command names, rehydrating a clean workspace binding. - Emit warnings when reserved command names are detected as locals.
- Add a shell test that simulates IRB input and asserts reserved command locals are not preserved while normal locals are preserved.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
hbase-shell/src/test/ruby/shell/general_test_cluster.rb |
Adds a regression test using a mock IRB input method to validate reserved-command shadowing prevention. |
hbase-shell/src/main/ruby/irb/hirb.rb |
Implements the reserved-command local-variable detection/removal logic inside HIRB#eval_input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…d safe workspace setter
|
Hi @liuxiaocs7 , I have applied copilot suggestions , Please take a look. |
|
Just a gentle follow-up on this PR. I have addressed all the review comments and verified that the local tests are passing. Please let me know if anything else is needed or if this is good to go. |
Why are the changes needed?
As reported in HBASE-28660, when a user enters an incorrect command like
list_namespace, 'ns.*', the JRuby parser mistakenly creates a local variable namedlist_namespaceinitialized tonilbefore throwing a SyntaxError. Because Ruby prioritizes local variables over method calls, subsequent validlist_namespacecommands return empty/nil instead of executing the actual shell command.How does this PR fix the problem?
hirb.rb'seval_inputloop.WARN: '<command>' is a reserved HBase command. Local variable assignment ignored.).general_test_cluster.rbto cover direct assignments, syntax errors, and safe variable preservations.Tests run
Ran the shell tests locally and verified that the behavior works as expected without regressions.
mvn test -Dtest=TestShell -pl hbase-shell(All tests passed).