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

Fix validateNoDuplicateNames #4815

Merged
merged 2 commits into from
May 3, 2022

Conversation

chuangw6
Copy link
Member

@chuangw6 chuangw6 commented May 1, 2022

Changes

Fixes #4814

Prior to this fix, validateNoDuplicateNames function was intended to check case-insensitive duplications against names, but it saved original names into the set to compare, which can cause that duplicate names cannot be checked correctly - mentioned in #4814.

In this fix:

  • validateNoDuplicateNames will save names in lower case into the check set and then compare.
  • Unit tests are added for this fix.
  • Document that parameter names are case insensitive in the docs/tasks.md file and add links to this file's Specifying Parameters section in other relevant files.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 1, 2022
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 1, 2022
@chuangw6
Copy link
Member Author

chuangw6 commented May 2, 2022

/assign @dibyom

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this fix @chuangw6!

please add more context to the commit message and PR description per the commit message standards, which can include the detail that the function was intended to be case insensitive as demonstrated by lines 150 and 155 below:

// Case insensitive.
// If byIndex is true, the error will be reported by index instead of by key.
func validateNoDuplicateNames(names []string, byIndex bool) (errs *apis.FieldError) {
seen := sets.NewString()
for i, n := range names {
if seen.Has(strings.ToLower(n)) {

also, please add documentation that the params are case-insensitive (skimmed through the docs and they don't seem to mention this)

@dibyom
Copy link
Member

dibyom commented May 2, 2022

LGTM!
We should definitely update the docs to mention params are case insensitive

Prior to this fix, validateNoDuplicateNames function was intended to check
case-insensitive duplications against names, but it saved original names
into the set to compare.

In this fix, validateNoDuplicateNames will save names in lower case into
the check set and then compare.
@chuangw6 chuangw6 force-pushed the fix-validate-duplicate-param branch from b656a84 to f656351 Compare May 2, 2022 22:25
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 2, 2022
@chuangw6 chuangw6 force-pushed the fix-validate-duplicate-param branch from f656351 to 342caa7 Compare May 2, 2022 22:26
@chuangw6
Copy link
Member Author

chuangw6 commented May 2, 2022

thanks for this fix @chuangw6!

please add more context to the commit message and PR description per the commit message standards, which can include the detail that the function was intended to be case insensitive as demonstrated by lines 150 and 155 below:

// Case insensitive.
// If byIndex is true, the error will be reported by index instead of by key.
func validateNoDuplicateNames(names []string, byIndex bool) (errs *apis.FieldError) {
seen := sets.NewString()
for i, n := range names {
if seen.Has(strings.ToLower(n)) {

also, please add documentation that the params are case-insensitive (skimmed through the docs and they don't seem to mention this)

Thanks! Done!

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2022
@chuangw6 chuangw6 force-pushed the fix-validate-duplicate-param branch from 342caa7 to bf7cde2 Compare May 2, 2022 23:15
@tekton-robot tekton-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 2, 2022
Prior to this commit, parameter names will be checked against duplicates
(case-insensitive), but it's not mentioned in the documentation that
parameter names are case-insensitive.

Also add links to tasks.md's "Specifying `Parameters`" section in other
related files.
@chuangw6 chuangw6 force-pushed the fix-validate-duplicate-param branch from bf7cde2 to 4b8073f Compare May 2, 2022 23:27
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@abayer
Copy link
Contributor

abayer commented May 3, 2022

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 3, 2022
@abayer
Copy link
Contributor

abayer commented May 3, 2022

/retest

@tekton-robot tekton-robot merged commit c1d68d6 into tektoncd:main May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Case-insensitive duplication check in TaskRunSpec's params
6 participants