Bug 2002995 - hammer completion not working
Summary: hammer completion not working
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.9.6
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: 6.11.0
Assignee: satellite6-bugs
QA Contact: sganar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-09-10 09:53 UTC by bkaraore
Modified: 2022-07-05 14:29 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-07-05 14:29:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
full help output (570.40 KB, application/octet-stream)
2021-11-08 08:29 UTC, bkaraore
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32861 0 Normal Closed hammer full-help fails if apidoc entry is not available 2021-11-11 15:46:32 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:29:46 UTC

Description bkaraore 2021-09-10 09:53:32 UTC
Description of problem:
hammer command completion not working on the shell.

Version-Release number of selected component (if applicable):
tfm-rubygem-hammer_cli-2.3.0-1.el7sat.noarch

How reproducible:
Always

Steps to Reproduce:
1.Tab command completion does not work in hammer shell

Actual results:
Command completion does not work in hammer shell

Expected results:
Command completion should work in hammer shell

Additional info:
Red Hat Enterprise Linux Server release 7.9 (Maipo)

hammer --version
hammer (2.3.0)
 * hammer_cli_foreman (2.3.1)
 * hammer_cli_foreman_admin (1.0.0)
 * hammer_cli_foreman_ansible (0.3.2)
 * hammer_cli_foreman_azure_rm (0.2.0)
 * hammer_cli_foreman_bootdisk (0.3.0)
 * hammer_cli_foreman_discovery (1.0.2)
 * hammer_cli_foreman_docker (0.0.7)
 * hammer_cli_foreman_openscap (0.1.12)
 * hammer_cli_foreman_remote_execution (unknown version)
 * hammer_cli_foreman_tasks (unknown version)
 * hammer_cli_foreman_templates (0.2.0)
 * hammer_cli_foreman_virt_who_configure (unknown version)
 * hammer_cli_katello (0.24.0.2)

Comment 1 bkaraore 2021-09-10 09:57:49 UTC
When trying completion on hammer with double tab it reports an error
# hammer (tab)[tab]

environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead.
report command is deprecated and will be removed in one of the future versions. Please use config-report command instead.
Error: undefined method `singular_name' for nil:NilClass
environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead.
report command is deprecated and will be removed in one of the future versions. Please use config-report command instead.
Error: undefined method `singular_name' for nil:NilClass

# hammer-complete
environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead.
report command is deprecated and will be removed in one of the future versions. Please use config-report command instead.
Error: undefined method `singular_name' for nil:NilClass

Comment 2 Brad Buckingham 2021-09-13 13:11:35 UTC
Do you have a reproducer that we can access?

We are no longer seeing this issue on our 6.10 configuration.

Thanks!

Comment 3 Oleh Fedorenko 2021-09-13 13:15:26 UTC
In addition to what Brad said, have you tried the following:

1. Re-generate API docs: foreman-rake apipie:cache
2. Update hammer's cache: hammer --reload-cache
3. Re-build completion: hammer prebuild-bash-completion

Comment 5 Oleh Fedorenko 2021-09-13 14:48:02 UTC
Hm, I've tried hard to reproduce it, but unfortunatelly couldn't make it. Does this error occurre only in bash completion or this error is also shown when you try to run the actual command typed without completion? If this error occurres even without completion context, could you please share the debug log?

Comment 6 Oleh Fedorenko 2021-10-21 09:33:34 UTC
Actually, it could help if you run hammer full-help command to see if there any failures. If they are, please provide the debug output.

Comment 7 bkaraore 2021-11-01 11:14:25 UTC
All the options are printed when I run #hammer full-help command. But there is an exception at the end with
"Error: undefined method `[]' for nil:NilClass"

@Oleh which debug logs you want to get?

Comment 8 Oleh Fedorenko 2021-11-02 13:34:15 UTC
Sorry for not mentioning: you can observe hammer's debug output if you run any command with -d option:

> hammer -d full-help

And since there is an error for full-help command the debug output could help find a place where it fails. My assumption is that API docs aren't complete. This can happen if there is a plugin for hammer without corresponding plugin for Foreman. If we find why full-help fails, we probably could fix the completion as well.

Comment 9 bkaraore 2021-11-08 08:26:41 UTC
I have gathered full output. I am attaching full output and it shows some ERRORS like below:

```
[DEBUG 2021-11-08T09:22:26 Exception] Using exception handler HammerCLI::ExceptionHandler#handle_general_exception
[ERROR 2021-11-08T09:22:26 Exception] Error: undefined method `[]' for nil:NilClass
Error: undefined method `[]' for nil:NilClass
[ERROR 2021-11-08T09:22:26 Exception]

NoMethodError (undefined method `[]' for nil:NilClass):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-2.3.1/lib/hammer_cli_foreman/commands.rb:297:in `help'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:26:in `print_help'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:32:in `block in print_help'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `print_help'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:32:in `block in print_help'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `print_help'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:12:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/bin/hammer:147:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'
```

Comment 10 bkaraore 2021-11-08 08:29:53 UTC
Created attachment 1840665 [details]
full help output

Comment 17 sganar 2021-12-21 13:43:59 UTC
Verified.

Tested on Satellite 7.0.0 Snap 3.0

Steps Followed:

1. hammer [tab] [tab]

2. hammer-complete

Observation: 

hammer tab completion is working fine

Observing new error for hammer -d full-help

report command is deprecated and will be removed in one of the future versions. Please use config-report command instead.
Error: uninitialized constant HammerCLIForeman::CommandExtensions::PuppetEnvironment

Since it is not related to this BZ, hence verifying it

Comment 23 errata-xmlrpc 2022-07-05 14:29:38 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498


Note You need to log in before you can comment on or make changes to this bug.