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

Tags without a classification cause errors #18177

Merged

Conversation

juliancheal
Copy link
Member

@juliancheal
Copy link
Member Author

@miq-bot add_label bug, gaprindashvili/yes

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliancheal This looks good but it would be best to add a quick test with a tag without a classification before merging

@juliancheal
Copy link
Member Author

@gtanzillo Yes sure, meant to ask you about that yesterday.

@JPrause
Copy link
Member

JPrause commented Nov 9, 2018

@miq-bot add_label blocker

@miq-bot miq-bot added the blocker label Nov 9, 2018
@JPrause
Copy link
Member

JPrause commented Nov 9, 2018

@juliancheal please also add the hammer/yes label

@juliancheal
Copy link
Member Author

@miq-bot add_label hammer/yes

@Fryguy
Copy link
Member

Fryguy commented Nov 9, 2018

Higher level question... Why would a tag not have a classification? That seems like a case that shouldnt happen.

cc @kbrock as I know you've looked at this from a performance perspective before

@Fryguy
Copy link
Member

Fryguy commented Nov 9, 2018

@juliancheal can you also fix the rubocop issue?

@juliancheal
Copy link
Member Author

Higher level question... Why would a tag not have a classification? That seems like a case that shouldnt happen.

@Fryguy Right, we shouldn't but from the BZ they do.

Julian Cheal added 2 commits November 9, 2018 12:37
Tests for situations where classification is nil, yet tag.show is true
@juliancheal juliancheal force-pushed the fix_tags_without_classifications_errors branch from cc0b8d5 to 8bb45d6 Compare November 9, 2018 17:41
@miq-bot
Copy link
Member

miq-bot commented Nov 9, 2018

Checked commits juliancheal/manageiq@7a2aad3~...8bb45d6 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@juliancheal
Copy link
Member Author

To summarise the offline conversation I had with @gtanzillo. The customer has a situation where they have Tags that return true for tag.show which means the code reaches this else statement https://github.com/ManageIQ/manageiq/blob/master/app/models/tag.rb#L148

However at the same time, there is no classification.name or classification.description. So the code would crash by calling a method on nil.

This "fix" makes it so the code doesn't 💣 out, but it would be good to find the reason we're in this situation.

/cc @Fryguy @kbrock

@lpichler
Copy link
Contributor

lpichler commented Nov 9, 2018

Higher level question... Why would a tag not have a classification? That seems like a case that shouldnt happen.

I was facing with this cases on CUs's DBs also (#17883)

@juliancheal
Copy link
Member Author

🍏 @gtanzillo

@gtanzillo gtanzillo added this to the Sprint 99 Ending Nov 19, 2018 milestone Nov 9, 2018
@gtanzillo gtanzillo merged commit 3217a89 into ManageIQ:master Nov 9, 2018
@kbrock
Copy link
Member

kbrock commented Nov 10, 2018

@Fryguy ugh - late to the party
Yes, all tags need to have classifications for them to work.
This is a bug in the database, not in our code.

Maybe the custom attribute stuff?

simaishi pushed a commit that referenced this pull request Nov 12, 2018
…ations_errors

Tags without a classification cause errors

(cherry picked from commit 3217a89)

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

Hammer backport details:

$ git log -1
commit bac84088f5b756e7d136dd8746612defa93c3487
Author: Gregg Tanzillo <[email protected]>
Date:   Fri Nov 9 13:35:27 2018 -0500

    Merge pull request #18177 from juliancheal/fix_tags_without_classifications_errors
    
    Tags without a classification cause errors
    
    (cherry picked from commit 3217a89bb0d0c76d7a482eada25e93e4f35ae2f4)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1632901

simaishi pushed a commit that referenced this pull request Nov 12, 2018
…ations_errors

Tags without a classification cause errors

(cherry picked from commit 3217a89)

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

Gaprindashvili backport details:

$ git log -1
commit 50d3412e5425fb46a93fb2afed837f30d3ab2c17
Author: Gregg Tanzillo <[email protected]>
Date:   Fri Nov 9 13:35:27 2018 -0500

    Merge pull request #18177 from juliancheal/fix_tags_without_classifications_errors
    
    Tags without a classification cause errors
    
    (cherry picked from commit 3217a89bb0d0c76d7a482eada25e93e4f35ae2f4)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1648948

@@ -103,6 +103,18 @@
expect(categorization).to eq(expected_categorization)
end

it "tag with nil classification" do
@tag.classification = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have been @tag.classification.delete?

If I do this and issue @tag.reload, I get:

  1) Tag categorization tag with nil classification
     Failure/Error: expect(@tag.show).to eq(true)

       expected: true
            got: nil

       (compared using ==)
     # ./spec/models/tag_spec.rb:117:in `block (3 levels) in <top (required)>'

Note, I'm here because rails 5.0 looks to have been returning a cached classification when @tag.categorization calls @tag.category in show. Because this was failing, I changed my tests locally to do @tag.classification.delete and it fails as shown above in both rails 5.0 and 5.1.

I'm not sure how any of the @category expectations are set, such as @category.name below:
To get to the category, you need to navigate through using @tag.classification.parent (what category does I think). If the classification is nil or deleted, category should also be nil, which would cause show to be nil.

😕

Copy link
Member

@jrafanie jrafanie Nov 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, I believe we're relying on @tag.category to return the cached parent of the classification's parent. If you delete the classification, it fails. If you upgrade to rails 5.1, the classification is nil so the category (classification parent) is also nil.

I believe this test is wrong. I think.

nizaminabeel pushed a commit to nizaminabeel/manageiq that referenced this pull request Dec 11, 2018
…lassifications_errors

Tags without a classification cause errors

(cherry picked from commit 3217a89)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1648948
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.

9 participants