Use configured credentials for renovate-config-validator
#12272 opened on Oct 22, 2021
Description
How are you running Renovate?
Self-hosted
Please select which platform you are using if self-hosting.
gitlab.com
If you're self-hosting Renovate, tell us what version of Renovate you run.
28.1.5
Describe the bug
As a maintainer of shared renovate configs I am trying to validate these configs in merge requests before they are merged and used by many projects and potentially break their configuration. These configurations are hosted in a private Gitlab repository.
To do that I'm using the renovate-config-validator binary and pass each configuration file like this:
for file in *.json; do echo "Validating file $file"; RENOVATE_CONFIG_FILE=$file renovate-config-validator; done
These configuration files might extend other configuration files in the same repository.
It seems that the renovate-config-validator binary does not use the configured RENOVATE_TOKEN so it fails saying that it cannot access the configured preset:
ERROR: cookiecutter.json is not valid Renovate config
"err": {
"validationError": "Cannot find preset's package (gitlab>our-private-repo:automerge)",
"message": "config-validation",
"stack": "Error: config-validation\n at resolveConfigPresets (/usr/src/app/node_modules/renovate/lib/config/presets/index.ts:266:25)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at validateConfig (/usr/src/app/node_modules/renovate/lib/config/validation.ts:311:23)\n at validate (/usr/src/app/node_modules/renovate/lib/config-validator.ts:34:15)\n at /usr/src/app/node_modules/renovate/lib/config-validator.ts:96:9"
}
P.S.: I'm not sure if a reproduction repo would help , because it probably only occurs in private repos. I could create a public repo that could be forked as a private repo.
Relevant debug logs
ubuntu@9cea5205440f:/repo$ RENOVATE_CONFIG_FILE=cookiecutter.json renovate-config-validator
DEBUG: Using RE2 as regex engine
DEBUG: Checking for config file in /repo/cookiecutter.json
INFO: Validating cookiecutter.json
DEBUG: GitLab API 404
"url": "https://gitlab.com/api/v4/projects/our-private-repo/repository/branches"
DEBUG: Failed to retrieve automerge.json from repo
"statusCode": 404,
"url": "https://gitlab.com/api/v4/"
DEBUG: Preset fetch error
"preset": "gitlab>our-private-repo:automerge",
"err": {
"message": "dep not found",
"stack": "Error: dep not found\n at fetchJSONFile (/usr/src/app/node_modules/renovate/lib/config/presets/gitlab/index.ts:53:11)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at fetchPreset (/usr/src/app/node_modules/renovate/lib/config/presets/util.ts:47:19)\n at getPreset (/usr/src/app/node_modules/renovate/lib/config/presets/index.ts:180:22)\n at resolveConfigPresets (/usr/src/app/node_modules/renovate/lib/config/presets/index.ts:255:27)\n at validateConfig (/usr/src/app/node_modules/renovate/lib/config/validation.ts:311:23)\n at validate (/usr/src/app/node_modules/renovate/lib/config-validator.ts:34:15)\n at /usr/src/app/node_modules/renovate/lib/config-validator.ts:96:9"
}
INFO: Throwing preset error
"validationError": "Cannot find preset's package (gitlab>our-private-repo:automerge)"
ERROR: cookiecutter.json is not valid Renovate config
"err": {
"validationError": "Cannot find preset's package (gitlab>our-private-repo:automerge)",
"message": "config-validation",
"stack": "Error: config-validation\n at resolveConfigPresets (/usr/src/app/node_modules/renovate/lib/config/presets/index.ts:266:25)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at validateConfig (/usr/src/app/node_modules/renovate/lib/config/validation.ts:311:23)\n at validate (/usr/src/app/node_modules/renovate/lib/config-validator.ts:34:15)\n at /usr/src/app/node_modules/renovate/lib/config-validator.ts:96:9"
}
Have you created a minimal reproduction repository?
No reproduction repository