-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix: ignore empty labels during label merge and templating #14322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change affects more than just "don't set empty labels" and could have unforeseen reason implications. Please either fix the narrow scope or else start an issue to discuss wider requirements.
I also recommend you simplify to use is.truthy and is.nonEmptyString
lib/workers/pr/index.ts
Outdated
template.compile(label, config) | ||
); | ||
return [...new Set([...labels, ...addLabels])] | ||
.filter((el) => el !== null && el !== undefined && el.trim() !== '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter((el) => el !== null && el !== undefined && el.trim() !== '') | |
.filter(is.nonEmptyString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing. In this case, is.nonEmptyString
does not cover a case when the string contains multiple white space characters.
It still require trim
e.g. .filter((el) => is.nonEmptyString(el) && el.trim() !== '')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for help. Ive updated the logic with .filter((el) => is.nonEmptyString(el) && !is.emptyStringOrWhitespace(el))
and created a proposal to add nonEmptyStringOrWhitespace
sindresorhus/is#158
lib/workers/pr/index.ts
Outdated
return [...new Set([...labels, ...addLabels])] | ||
.filter((el) => el !== null && el !== undefined && el.trim() !== '') | ||
.map((label) => template.compile(label, config)) | ||
.filter((el) => el !== null && el.trim() !== ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter((el) => el !== null && el.trim() !== ''); | |
.filter(is.nonEmptyString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated with .filter((el) => is.nonEmptyString(el) && !is.emptyStringOrWhitespace(el))
Tested. Make sense Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Thanks for the suggestions. Can I have please an idea of how to reduce the scope for the bug described? |
Hi @ivankatliarchuk! 👋 Thank you for your contribution! You can mark a PR as a "draft" from within GitHub. You don't need to put Please read the GitHub docs, Changing the stage of a pull request, and then mark the PR as draft within GitHub, and remove the |
@rarkins don't you want to edit the PR title first, before you merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
Hi, @HonkingGoose. Apologies spent too much time working on GitLab. The Draft button there is a bit more visible. I found it btw -;) |
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Head branch was pushed to by a user without write access
🎉 This PR is included in version 31.89.7 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Changes
When any string in
label
orandLabel
is empty, Github API failes withResponse code 422 (Unprocessable Entity)
. The fix should improve label API resiliency, as it possible, that during runtime some labels may not be set, or empty.The code
The first filter makes sure that input labels are not empty, not nuls and etc. In order to provide flexible configuration, Renovate supports using "templates", and when the value is not exist, not set or does not apply for a use case,
handlebars
return an empty string. Github API does not let to set empty label.Context
Describe the bug
Any of
depType
,datasource
orupdateType
empty at execution time.or
Environment variable
OPTIONAL_TEAM_LABEL
is optional for team B but mandatory for team ARelevant debug logs
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: