Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine Credential: don't access options hash when null #6466

Conversation

mzazrivec
Copy link
Contributor

We need to be able correctly handle ansible credential resources, which have options hash set to nil / null.

  1. Create a machine credential, set username & password, nothing else!
  2. Try to edit the credential
  3. Observe the following javascript error:
angular.js:14961 TypeError: Cannot read property 'userid' of null
    at ansible_credentials_form_controller.self-d9df03bc8f1484db2a02d83c534e63b7e78fa04f4ba970174ce3945bb8a3fda3.js?body=1:122
    at Array.forEach (<anonymous>)
    at ansible_credentials_form_controller.self-d9df03bc8f1484db2a02d83c534e63b7e78fa04f4ba970174ce3945bb8a3fda3.js?body=1:114
    at processQueue (angular.js:17330)
    at angular.js:17378
    at Scope.$digest (angular.js:18515)
    at angular.js:18835
    at completeOutstandingRequest (angular.js:6439)
    at angular.js:6718 "Possibly unhandled rejection: {}"

Alternatively, you can create the problematic resource in rails console with:

machine01 = Authentication.select{|auth| auth.type == "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::MachineCredential"}.first.dup
machine01.name = 'machine01'
machine01.options = nil
machine01.save

https://bugzilla.redhat.com/show_bug.cgi?id=1775093

@mzazrivec mzazrivec changed the title Don't access options when null Machine Credential: don't access options when null Nov 29, 2019
@mzazrivec mzazrivec changed the title Machine Credential: don't access options when null Machine Credential: don't access options hash when null Nov 29, 2019
@martinpovolny martinpovolny merged commit 9c5532f into ManageIQ:master Dec 2, 2019
@martinpovolny martinpovolny added this to the Sprint 126 Ending Dec 9, 2019 milestone Dec 2, 2019
@martinpovolny martinpovolny self-assigned this Dec 2, 2019
@mzazrivec mzazrivec deleted the correctly_handle_machine_credential_resource_without_options branch December 2, 2019 11:35
simaishi pushed a commit that referenced this pull request Dec 16, 2019
…ential_resource_without_options

Machine Credential: don't access options hash when null

(cherry picked from commit 9c5532f)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1784189
@simaishi
Copy link
Contributor

Ivanchuk backport details:

$ git log -1
commit 46c1ee3398113ec0fd417ab8b8d25bc0b7b45387
Author: Martin Povolny <mpovolny@redhat.com>
Date:   Mon Dec 2 12:06:27 2019 +0100

    Merge pull request #6466 from mzazrivec/correctly_handle_machine_credential_resource_without_options

    Machine Credential: don't access options hash when null

    (cherry picked from commit 9c5532f7a2e681e450ff4750fd2967b1ae116312)

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1784189

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

Successfully merging this pull request may close these issues.

None yet

3 participants