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

Parse models of > 3 namespaces #16704

Merged

Conversation

imtayadeway
Copy link
Contributor

It was found that the regex for parsing tags had edge cases that would
cause it to never finish evaluating. The solution to that at the time
was to limit models to an arbitrary number (3) of namespaces. The bug
below describes a tag that was created with a model more deeply nested
than that (which I have used as a test case). Since there is no number
that can be guaranteed to always work, we need a more sophisticated
regex that won't loop infinitely while also supporting arbitrarily
deep nesting.

I've attempted to do that here, while fixing some poorly formed tests
that failed to match the new pattern.

I will only add that this regex has probably reached the point where
it's a burden to maintain, and that we should look into reimplenting a
formal parser for fields/tags in the near future.

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

/cc @lgalis

@@ -1,6 +1,6 @@
class MiqExpression::Tag < MiqExpression::Target
REGEX = /
(?<model_name>([[:alnum:]]*(::)?){4})
(?<model_name>([[:upper:]][[:alnum:]]*(::[[:upper:]][[:alnum:]]*)*)?)
Copy link
Member

@Fryguy Fryguy Dec 20, 2017

Choose a reason for hiding this comment

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

You might want to make the inner captures into non-capturing groups

It was found that the regex for parsing tags had edge cases that would
cause it to never finish evaluating. The solution to that at the time
was to limit models to an arbitrary number (3) of namespaces. The bug
below describes a tag that was created with a model more deeply nested
than that (which I have used as a test case). Since there is no number
that can be guaranteed to always work, we need a more sophisticated
regex that won't loop infinitely while also supporting arbitrarily
deep nesting.

I've attempted to do that here, while fixing some poorly formed tests
that failed to match the new pattern.

I will only add that this regex has probably reached the point where
it's a burden to maintain, and that we should look into reimplenting a
formal parser for fields/tags in the near future.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1524889
@imtayadeway imtayadeway force-pushed the bug/miq-expression-model-namespaces branch from 92cb827 to e0fa9a8 Compare December 20, 2017 19:21
@miq-bot
Copy link
Member

miq-bot commented Dec 20, 2017

Checked commit imtayadeway@e0fa9a8 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@Fryguy Fryguy merged commit faeac8b into ManageIQ:master Dec 20, 2017
@Fryguy Fryguy added this to the Sprint 76 Ending Jan 1, 2018 milestone Dec 20, 2017
simaishi pushed a commit that referenced this pull request Jan 3, 2018
@simaishi
Copy link
Contributor

simaishi commented Jan 3, 2018

Gaprindashvili backport details:

$ git log -1
commit 19c0b03b879a3c58b38f084e31896a427756666b
Author: Jason Frey <fryguy9@gmail.com>
Date:   Wed Dec 20 15:30:47 2017 -0500

    Merge pull request #16704 from imtayadeway/bug/miq-expression-model-namespaces
    
    Parse models of > 3 namespaces
    (cherry picked from commit faeac8b0829887e1364778058bbeb8c5edf6672a)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1530648

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.

5 participants