Repository navigation
fix(labels): say which values were refused instead of "command args missing" - #376
Merged
Merged
Conversation
…issing" `/kind foo` where `foo` is not an allowed value, and the same for every prefixed or dynamic label command and its `/remove-<key>` form, failed with `kind: command args missing from body` although an argument was given: requestedLabels threw that message whenever no allowed value was left after filtering. The message now says what happened, e.g. `kind: no allowed value in "foo"; allowed: bug, feature` (`allowed: none` for an empty section). A command with no argument at all keeps `<key>: command args missing from body`. Tests: the eleven unit cases under __tests__/label/ and the bundle case in prefixedRemoveArms.test.ts (cncf#341) that passed a disallowed value asserted the old text; they now assert the new one. New cases: several disallowed values, an empty section, and /lifecycle, /remove-lifecycle and (bundle) /kind with no value keeping the missing-args message. docs/labeling.md describes both messages. Signed-off-by: Jeffrey Sica <me@jeefy.dev>
Signed-off-by: Jeffrey Sica <me@jeefy.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug.
/kind foowherefoois not an allowed value (and the same for every prefixed/dynamic label command and its/remove-<key>form) failed withkind: command args missing from bodyalthough an argument was given:requestedLabelsinsrc/labels/prefixed.tsthrew that message whenever no allowed value survived filtering.Fix. Args given but none allowed now fails with e.g.
kind: no allowed value in "foo"; allowed: failing-test, cleanup(allowed: nonefor an empty section). No argument at all keeps<key>: command args missing from body./remove-<key>of an allowed value that is not on the issue was never on this path (it is a no-op logged at debug) and is unchanged; plain/remove(src/labels/remove.ts) is a separate function and is untouched.Tests changed (they pinned the old text for a disallowed value).
__tests__/label/{area,kind,priority,label}.test.ts(add + remove cases),dynamic.test.ts,lifecycle.test.ts(2): now assert the new message.__tests__/bundle/prefixedRemoveArms.test.ts(test(bundle): drive the prefixed label commands' and /remove's failure arms through dist/index.js #341): the/kind not-allowedcase asserts the new message.Added: several disallowed values, an empty section (
allowed: none),/lifecycleand/remove-lifecyclewith no value (unit) and/kindwith no value (bundle) keeping the missing-args message.docs/labeling.mddescribes both messages.dist/index.jsregenerated withnpm run all.Verified locally:
npm run all(1851 tests),npm run test:coverage(thresholds pass), secondnpm run packleavesdist/clean,npm run test:coverage:e2e(215 tests).