[Bug] Improper regex used in removeTemplates
when parsing docker-compose files
#32967
Replies: 4 comments 7 replies
-
I was sure I had responded to this yesterday, but can't find any comment here, or find a duplicate discussion. This is related though: #33105 @viceice I think the jinja2 template removal seems too aggressive. It's not just removing templates, it's removing whitespace and a colon around it in an attempt to "repair" the result too, but that ends up breaking things like above. |
Beta Was this translation helpful? Give feedback.
-
maybe the reflex need to be |
Beta Was this translation helpful? Give feedback.
-
Since we have now a more proper way of stripping variables with I tested without it on the |
Beta Was this translation helpful? Give feedback.
-
How are you running Renovate?
A Mend.io-hosted app
If you're self-hosting Renovate, tell us which platform (GitHub, GitLab, etc) and which version of Renovate.
No response
Please tell us more about your question or problem
A couple of months ago, I noticed that suddenly, almost all of my docker-compose dependencies weren't detected anymore.
After some research, I've finally figured it out today. Recently, this PR was merged: #31206
That PR added an option to remove Jinja2 templates from a YAML file, so the YAML parser can properly parse it.
However, the regex used to remove certain templates seems to be incorrect. See the following docker-compose file using Jinja2:
Now let's look at what
parseSingleYaml
does. IfremoveTemplates
is set, it runs:content.replace(regEx(/\s+{{.+?}}:.+/gs), '')
renovate/lib/util/yaml.ts
Lines 143 to 151 in f40c035
If we put that regex and the contents into something like RegExr (link contains reproduction), we can see almost the whole file is matched, which then explains why Renovate is unable to parse any of my docker-compose files:
So then, what's the fix? It seems that the regex can't find the end of the template.
So my first attempt was wrapping it in quotation marks, which unfortunately didn't work as well yet.
I also had to remove the Ansible header for it to work:
I'm not entirely sure what the proper fix for this is, but I at least thought I'd report it. If I have to live with this, then that's perfectly fine as well for me, since in the end, YAML will parse it properly anyway (it just ignores the quotation marks).
Logs (if relevant)
No response
Beta Was this translation helpful? Give feedback.
All reactions