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

YAMLException on GitLab reference syntax #9620

Closed
1 of 4 tasks
dlouzan opened this issue Apr 19, 2021 · 5 comments · Fixed by #9741
Closed
1 of 4 tasks

YAMLException on GitLab reference syntax #9620

dlouzan opened this issue Apr 19, 2021 · 5 comments · Fixed by #9741
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:bug Bug fix of existing functionality

Comments

@dlouzan
Copy link

dlouzan commented Apr 19, 2021

What Renovate type, platform and version are you using?

Latest GitLab template with 24.117.0 from https://gitlab.com/renovate-bot/renovate-runner/

Describe the bug

Renovate fails to extract a project that uses the !reference syntax, as discussed previously on #9162

This is loaded from a gitlab-ci include, outline structure:

.gitlab/ci_templates/.terraform-templates.yml:

.terraform-init:
  script:
    - terraform init ...

...

.terraform-plan:
  extends: .terraform-image
  script:
    - !reference [.terraform-init, script]
    - terraform plan

.gitlab-ci.yml:

include:
  - local: '/.gitlab/ci_templates/.terraform-templates.yml'

...

actual-job:
  stage: test
  extends:
    - .terraform-plan

Relevant debug logs

Click me to see logs
"err": {
  "name": "YAMLException",
  "reason": "unknown tag !<!reference>",
  "mark": {
    ...
  },
  "message": "unknown tag !<!reference> at line 29, column 43:\n     ... erence [.terraform-init, script]\n                                         ^",
         "stack": "YAMLException: unknown tag !<!reference> at line 29, column 43:\n     ... erence [.terraform-init, script]\n                                         ^\n    at generateError (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)\n    at throwError (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)\n    at composeNode (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1434:7)\n    at readBlockSequence (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:955:5)\n    at composeNode (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1358:12)\n    at readBlockMapping (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1089:11)\n    at composeNode (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)\n    at readBlockMapping (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1089:11)\n    at composeNode (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)\n    at readDocument (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1525:3)\n    at loadDocuments (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1588:5)\n    at load (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1614:19)\n    at Object.safeLoad (/usr/src/app/node_modules/js-yaml/lib/js-yaml/loader.js:1637:10)\n    at Object.extractAllPackageFiles (/usr/src/app/node_modules/renovate/lib/manager/gitlabci/extract.ts:103:18)\n    at Object.extractAllPackageFiles (/usr/src/app/node_modules/renovate/lib/manager/index.ts:62:17)\n    at Object.getManagerPackageFiles (/usr/src/app/node_modules/renovate/lib/workers/repository/extract/manager-files.ts:33:29)\n    at /usr/src/app/node_modules/renovate/lib/workers/repository/extract/index.ts:48:28\n    at async Promise.all (index 0)\n    at Object.extractAllDependencies (/usr/src/app/node_modules/renovate/lib/workers/repository/extract/index.ts:46:26)\n    at Object.extract (/usr/src/app/node_modules/renovate/lib/workers/repository/process/extract-update.ts:82:20)"
       },
       "file": ".gitlab/ci_templates/.terraform-templates.yml"

Have you created a minimal reproduction repository?

Please read the minimal reproductions documentation to learn how to make a good minimal reproduction repository.

  • I have provided a minimal reproduction repository
  • I don't have time for that, but it happens in a public repository I have linked to
  • I don't have time for that, and cannot share my private repository
  • The nature of this bug means it's impossible to reproduce publicly

Additional context

@dlouzan dlouzan 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 Apr 19, 2021
@viceice
Copy link
Member

viceice commented Apr 19, 2021

Looks like my reference replace code got lost

@rarkins rarkins added the auto:reproduction A minimal reproduction is necessary to proceed label Apr 19, 2021
@github-actions
Copy link
Contributor

Hi there,

The Renovate team needs your help! Before we can start work on your issue we first need to know exactly what's causing the current behavior. A minimal reproduction helps us with this.

To get started, please read our guide on minimal reproductions to understand what is needed.

We may close the issue if you have not provided a minimal reproduction within two weeks. If you need more time, or are stuck, please ask for help or more time in a comment.

Good luck,

The Renovate team

@tmeijn
Copy link
Contributor

tmeijn commented Apr 27, 2021

Hey @viceice seems like you use replaceReferenceTags in the gitlabci manager but not in the gitlabci-include manager.

Also, the regex seems too strict. I think it's best to just match anything within the brackets after !reference like so: https://regex101.com/r/LGL79P/1, because it could be anything ([job name with space and no starting dot, artifacts, name]).

Monkey patching these two suggestions into my local Node modules seems to make it work again. I created a PR here with the suggested changes here.

@viceice viceice added reproduction:confirmed status:in-progress Someone is working on implementation priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others and removed auto:reproduction A minimal reproduction is necessary to proceed status:requirements Full requirements are not yet known, so implementation should not be started priority-5-triage labels Apr 27, 2021
@viceice
Copy link
Member

viceice commented Apr 27, 2021

PR looks good, but needs a test case

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 25.4.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:bug Bug fix of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants