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

Renovate PR Title bug when using {{ and }}. #12449

Open
picnic-sven opened this issue Nov 2, 2021 · 13 comments
Open

Renovate PR Title bug when using {{ and }}. #12449

picnic-sven opened this issue Nov 2, 2021 · 13 comments
Labels
help wanted Help is needed or welcomed on this issue priority-4-low Low priority, unlikely to be done unless it becomes important to more people type:bug Bug fix of existing functionality

Comments

@picnic-sven
Copy link

picnic-sven commented Nov 2, 2021

How are you running Renovate?

Self-hosted

Please select which platform you are using if self-hosting.

github.com

If you're self-hosting Renovate, tell us what version of Renovate you run.

27.18.1

Describe the bug

---- Updated bug report ----

Renovate PR Title bug

Given a repository with the structure:

root
—{{project_template}}/Pipfile
—project_template/Pipfile
.renovaterc.json

and upgrading packages using the Pipfile in {{project_template}} and project_template,
and the relevant configuration parameters in renovaterc.json are set like:

"packageRules": [
    {
    "groupName": "\\{{parentDir}}",
    "matchPackagePatterns": [".*"]
    }]

The expect PR has the following properties:

PR Title 1 = “TicketID {{project_template}}: Upgrade depedencies” 

PR Title 2 = “TicketID project_template: Upgrade dependencies” 

The actual PR has the following properties:

PR Title 1 = “TicketID : Upgrade” 

PR Title 2 = “TicketID project_template: Upgrade dependencies” 

Hence, the expected PR Title 1 is different than the actual PR Title 1.
PR Title 2 is handled correctly.

---- Original bug report ----

Renovate PR Title, CommitMessage and Branchname bug when using {{ and }}.

Given a repository with the structure:

root
—{{project_template}}/Pipfile
.renovaterc.json

and upgrading packages using the Pipfile in {{project_template}}
and the relevant configuration parameters in renovaterc.json are set like:

"additionalBranchPrefix": "{{parentDir}}-",
"commitMessagePrefix": “TicketID- {{parentDir}}:",

The expect PR has the following properties:

PR Title = “TicketID {{project_template}}: Upgrade {{Project_Name}}” 
commit message = “TicketID {{project_template}}: Upgrade dependency `package` to `new_version`” 
branch name = renovate/{{project_name}}-parentdir

The actual PR has the following properties:

PR Title = “TicketID : Upgrade” 
commit message = “TicketID : Upgrade dependency” 
branch name = renovate/-parentdir

An identical project named project_template is added to showcase the expected Renovate behaviour.

Minimal repository: https://github.com/picnic-sven/Renovate-PRTitle-CommitMessage-Branchname-Bug
Bug confirmed with Renovate versions 27.18.1 (self-hosted) and 28.21.4 (GH app)

Relevant debug logs

No response

Have you created a minimal reproduction repository?

I have linked to a minimal reproduction repository in the bug description

@picnic-sven picnic-sven added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality labels Nov 2, 2021
@rarkins
Copy link
Collaborator

rarkins commented Nov 2, 2021

Renovate compiles using handlebars. Have you experimented with any of its escaping techniques? when I googled I saw some recommendations for "Whitespace control": https://handlebarsjs.com/guide/expressions.html#whitespace-control

@picnic-sven
Copy link
Author

Renovate compiles using handlebars. Have you experimented with any of its escaping techniques? when I googled I saw some recommendations for "Whitespace control": https://handlebarsjs.com/guide/expressions.html#whitespace-control

Thanks for responding so quickly! I tried both approaches, but sadly no success.

Approach 1 (raw block helpers):

  • Only 1 PR was created.
  • PR title, commit message and branchname(renovate/rawparentdirraw) all incorrect.
  • Relevant logs:
DEBUG: branchifyUpgrades
DEBUG: Using group branchName template
DEBUG: Dependency pandas is part of group {{{{raw}}}}{{parentDir}}{{{{/raw}}}}
INFO: Disallowed variable name in template
{
  "varName": "raw",
  "template": "renovate/{{{{raw}}}}{{parentDir}}{{{{/raw}}}}-{{{groupSlug}}}"
}
DEBUG: Using group branchName template
DEBUG: Dependency pandas is part of group {{{{raw}}}}{{parentDir}}{{{{/raw}}}}
INFO: Disallowed variable name in template
{
  "varName": "raw",
  "template": "renovate/{{{{raw}}}}{{parentDir}}{{{{/raw}}}}-{{{groupSlug}}}"
}
DEBUG: 2 flattened updates found: pandas, pandas
DEBUG: Returning 1 branch(es)
INFO: Disallowed variable name in template(branch="renovate/-rawparentdirraw")
{
  "varName": "raw",
  "template": "TicketID {{{{raw}}}}{{parentDir}}{{{{/raw}}}}: Update dependency {{depName}} to {{#if isMajor}}v{{{newMajor}}}{{else}}{{#if isSingleVersion}}v{{{newVersion}}}{{else}}{{{newValue}}}{{/if}}{{/if}} "
}
INFO: Disallowed variable name in template(branch="renovate/-rawparentdirraw")
{
  "varName": "raw",
  "template": "TicketID {{{{raw}}}}{{parentDir}}{{{{/raw}}}}: Update dependency {{depName}} to {{#if isMajor}}v{{{newMajor}}}{{else}}{{#if isSingleVersion}}v{{{newVersion}}}{{else}}{{{newValue}}}{{/if}}{{/if}} "
}

Approach 2 (inline escapes):

  • No PR was created, only a renovate config issue ticket.
  • Relevant logs:
DEBUG: Found .renovaterc.json config file
DEBUG: Error parsing renovate config
{
  "renovateConfig": "{\n    \"$schema\": \"https://json.schemastore.org/renovate\",\n    \"additionalBranchPrefix\": \"\\{{parentDir}}-\",\n    \"commitMessagePrefix\": \"TicketID \\{{parentDir}}:\",\n    \"enabledManagers\": [\"pipenv\"],\n    \"packageRules\": [\n      {\n        \"groupName\": \"\\{{parentDir}}\",\n        \"matchPackagePatterns\": [\".*\"]\n      }\n    ],\n    \"prHeader\": \"Type: opt\\nTicket: TicketID\",\n    \"rangeStrategy\": \"bump\",\n    \"includePaths\": [\n      \"{{project_template}}/Pipfile\",\n      \"project_template/Pipfile\"\n    ]\n  }"
}
INFO: Repository has invalid config
{
  "error": {
    "validationSource": ".renovaterc.json",
    "validationError": "Invalid JSON (parsing failed)",
    "validationMessage": "JSON.parse error:  Unexpected token { in JSON at position 90",
    "message": "config-validation",
    "stack": "Error: config-validation\n    at checkForRepoConfigError (/home/ubuntu/renovateapp/node_modules/renovate/dist/workers/repository/init/merge.js:165:19)\n    at mergeRenovateConfig (/home/ubuntu/renovateapp/node_modules/renovate/dist/workers/repository/init/merge.js:185:5)\n    at async getRepoConfig (/home/ubuntu/renovateapp/node_modules/renovate/dist/workers/repository/init/config.js:15:14)\n    at async initRepo (/home/ubuntu/renovateapp/node_modules/renovate/dist/workers/repository/init/index.js:26:14)\n    at async Object.renovateRepository (/home/ubuntu/renovateapp/node_modules/renovate/dist/workers/repository/index.js:64:18)\n    at async renovateRepository (/home/ubuntu/renovateapp/app/worker/index.js:401:26)\n    at async /home/ubuntu/renovateapp/app/worker/index.js:645:5"
  }
}

@rarkins
Copy link
Collaborator

rarkins commented Nov 3, 2021

I think you should try Approach 2 with valid JSON. It should be possible to try it with JSON that parses. e.g. check in https://jsonlint.com/

@picnic-sven
Copy link
Author

Thanks again for the quick reply.
One step closer; adding \\ before {{parentDir}} at additionalBranchPrefix and commitMessagePrefix does result in the correct naming of the branch and commit message!

Adding \\ before {{parentDir}} at packageRules:[{“groupName”:{{parentDir}}”}] does not generate the expected PR Title.

Relevant logs:

DEBUG: migrated config
{
  "config": {
    "$schema": "https://json.schemastore.org/renovate",
    "additionalBranchPrefix": "\\{{parentDir}}-",
    "commitMessagePrefix": "TicketID \\{{parentDir}}:",
    "enabledManagers": [
      "pipenv"
    ],
    "packageRules": [
      {
        "groupName": "\\{{parentDir}}",
        "matchPackagePatterns": [
          ".*"
        ]
      }
    ],
    "prHeader": "Type: opt\nTicket: TicketID",
    "rangeStrategy": "bump",
    "includePaths": [
      "{{project_template}}/Pipfile",
      "project_template/Pipfile"
    ],
    "extends": [
      "github>whitesource/merge-confidence:beta"
    ]
  }
}

….

Creating PR(branch="renovate/{{project_template}}-parentdir")
{
  "prTitle": "TicketID : Update dependency pandas to ~=1.3.4"
}
DEBUG: Creating PR(branch="renovate/{{project_template}}-parentdir")
{
  "title": "TicketID : Update dependency pandas to ~=1.3.4",
  "head": "picnic-sven:renovate/{{project_template}}-parentdir",
  "base": "main",
  "draft": false
}

@rarkins
Copy link
Collaborator

rarkins commented Nov 4, 2021

groupName might get compiled twice. Can you set your repo to reproduce this particular problem?

@picnic-sven
Copy link
Author

I've update the README.md in my repo. The rest of the repo is setup to produce the unexpected behaviour.

@rarkins rarkins added help wanted Help is needed or welcomed on this issue priority-4-low Low priority, unlikely to be done unless it becomes important to more people status:ready and removed priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started labels Nov 5, 2021
@rarkins
Copy link
Collaborator

rarkins commented Nov 5, 2021

Unfortunately I can't work out any way to get it to work, but maybe on day someone will figure it out

@picnic-sven picnic-sven changed the title Renovate PR Title, CommitMessage and Branchname bug when using {{ and }}. Renovate PR Title bug when using {{ and }}. Nov 5, 2021
@olegkrivtsov

This comment was marked as resolved.

@rarkins

This comment was marked as outdated.

@olegkrivtsov

This comment was marked as resolved.

@klutchell

This comment was marked as off-topic.

@secustor

This comment was marked as off-topic.

@klutchell

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Help is needed or welcomed on this issue priority-4-low Low priority, unlikely to be done unless it becomes important to more people type:bug Bug fix of existing functionality
Projects
None yet
Development

No branches or pull requests

6 participants