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 param array indexing validation error reason and error log #6179

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented Feb 16, 2023

Changes

This commit fixes the param array indexing validation error reason and error log, the current reason and error messages are wrongly copied from object validation. This commit fixes this error and adds tests.

/kind bug

Signed-off-by: Yongxuan Zhang [email protected]

Submitter Checklist

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

  • N/A Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • N/A Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • N/A Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. release-note-none Denotes a PR that doesnt merit a release note. labels Feb 16, 2023
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 16, 2023
@Yongxuanzhang
Copy link
Member Author

This is divided from #6120 to break it into smaller prs

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@XinruZhang
Copy link
Member

/assign

pr.Status.MarkFailed(ReasonObjectParameterMissKeys,
"PipelineRun %s/%s parameters is missing object keys required by Pipeline %s/%s's parameters: %s",
pr.Status.MarkFailed(ReasonParamArrayIndexingInvalid,
"PipelineRun %s/%s array indexing params fail validation by Pipeline %s/%s's parameters: %s",
Copy link
Member

Choose a reason for hiding this comment

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

The error message looks confusing, could you please rephrase it a little bit? Is this function ValidateParamArrayIndex only for validating the out-of-boundary error? if so, can we make it clearer?

Thank you!

Copy link
Member Author

Choose a reason for hiding this comment

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

It is currently out-of-boundary error, but we want to add other checks later (the feature gate check).
Besides, the error from ValidateParamArrayIndex will also be added to this log. It will contain detailed log messages

Copy link
Member

Choose a reason for hiding this comment

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

Proposed codes suggestions has been merged, so I guess we can resolve this comment thread :) Thank you

pr.Status.MarkFailed(ReasonObjectParameterMissKeys,
"PipelineRun %s/%s parameters is missing object keys required by Pipeline %s/%s's parameters: %s",
pr.Status.MarkFailed(ReasonParamArrayIndexingInvalid,
"PipelineRun %s/%s array indexing params fail validation by Pipeline %s/%s's parameters: %s",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"PipelineRun %s/%s array indexing params fail validation by Pipeline %s/%s's parameters: %s",
"Failed to validate PipelineRun %s/%s: failed to validate Pipeline %s/%s's parameters: %s",

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we cannot use "Failed" as the first word, it fails the linter of duplicate workds. 😂

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

Copy link
Member

@XinruZhang XinruZhang left a comment

Choose a reason for hiding this comment

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

Thank you @Yongxuanzhang

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 16, 2023
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 16, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@XinruZhang
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 16, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@XinruZhang
Copy link
Member

/test pull-tekton-pipeline-beta-integration-tests

This seems like a network flake:

read tcp 10.53.120.3:41728->185.199.108.154:443: read: connection reset by peer

@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-beta-integration-tests

This seems like a network flake:

read tcp 10.53.120.3:41728->185.199.108.154:443: read: connection reset by peer

Yes I have seen this a lot recently

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 16, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

permanentError: true,
wantEvents: []string{
"Normal Started",
"Warning Failed PipelineRun foo/pipeline-param-array-out-of-bound array indexing params fail validation: failed to validate Pipeline foo/a-pipeline-with-array-indexing-params's parameters: non-existent param references:[$(params.some-param[2]",
Copy link
Member

Choose a reason for hiding this comment

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

missing closing brackets )] in [$(params.some-param[2]

Copy link
Member

Choose a reason for hiding this comment

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

is it possible to include the length of an array and the index in the error message non-existent param references:[$(params.some-param[2]? It will help the users to learn exactly what is the issue.

An array index \"2\" is out of bound, parameter \"some-param\" has two elements in \"$(params.some-param[2])\".

Copy link
Member Author

Choose a reason for hiding this comment

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

the bracket is missed intentionally otherwise it will fail the test. Since we will read the string as regex pattern, and if I adds bracket it will lead to the error. I don't know if there's a better way

Copy link
Member Author

Choose a reason for hiding this comment

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

is it possible to include the length of an array and the index in the error message non-existent param references:[$(params.some-param[2]? It will help the users to learn exactly what is the issue.

An array index \"2\" is out of bound, parameter \"some-param\" has two elements in \"$(params.some-param[2])\".

That's possible and makes sense. Maybe we could update it after #6180 is merged?

Copy link
Member

Choose a reason for hiding this comment

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

Can you please open an issue to track it?

Copy link
Member

Choose a reason for hiding this comment

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

the bracket is missed intentionally otherwise it will fail the test. Since we will read the string as regex pattern, and if I adds bracket it will lead to the error. I don't know if there's a better way

It looks half baked, how is the error returned to the user when they try to create a pipelineRun?

Copy link
Member Author

Choose a reason for hiding this comment

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

the bracket is missed intentionally otherwise it will fail the test. Since we will read the string as regex pattern, and if I adds bracket it will lead to the error. I don't know if there's a better way

It looks half baked, how is the error returned to the user when they try to create a pipelineRun?

I think this is just for test purpose, the regex function is only used in tests to check the events. Since event is complicated so it uses regex to match the content of the event. The users should be able to see the full events

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you please open an issue to track it?

Sure!

pr.Status.MarkFailed(ReasonObjectParameterMissKeys,
"PipelineRun %s/%s parameters is missing object keys required by Pipeline %s/%s's parameters: %s",
pr.Status.MarkFailed(ReasonParamArrayIndexingInvalid,
"PipelineRun %s/%s array indexing params fail validation: failed to validate Pipeline %s/%s's parameters: %s",
Copy link
Member

Choose a reason for hiding this comment

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

suggest rephrasing to:

PipelineRun \"%s/%s\" failed validation: Failed to validate Pipeline \"%s/%s\"'s parameter which has an invalid index while referring to an array: %s

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@pritidesai
Copy link
Member

thank you @Yongxuanzhang 👍

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pritidesai, XinruZhang

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 22, 2023
@Yongxuanzhang Yongxuanzhang requested review from pritidesai and removed request for wlynch and dibyom February 22, 2023 19:31
@Yongxuanzhang
Copy link
Member Author

Thanks! I opened an issue to fix comment: #6212

@XinruZhang
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2023
This commit fixes the param array indexing validation error reason and
error log, the current reason and error messages are wrongly copied from
object validation. This commit fixes this error and adds tests.

Signed-off-by: Yongxuan Zhang [email protected]
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 87.1% 87.4% 0.3

@XinruZhang
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2023
@tekton-robot tekton-robot merged commit 991fb56 into tektoncd:main Feb 22, 2023
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants