Skip to content

Improve the error message when invalid combination - #5566

Merged
knative-prow-robot merged 2 commits into
knative:masterfrom
nak3:friendly-error
Oct 3, 2019
Merged

knative-prow-robot merged 2 commits into
knative:masterfrom
nak3:friendly-error

Conversation

@nak3

@nak3 nak3 commented Sep 17, 2019

Copy link
Copy Markdown
Contributor

Proposed Changes

This PR is basically same idea with the fix of #5382.

When invalid combination is configured, the ErrInvalidValue is printed for now.
It is not accurate message and will mislead users.

To fix it, this patch prints accurate message with ErrGeneric.

BEFORE:

invalid value: true: spec.traffic[0].latestRevision

AFTER:

May not set revisionName "hello-example-dk7nd" when latestRevision is true: spec.traffic[0].latestRevision

for following combination.

  traffic:
  - latestRevision: true
    revisionName: hello-example-dk7nd
    percent: 100

Also, ref: knative/pkg#638

/lint

Release Note

NONE

This PR is basically same idea with the fix of knative#5382.

When invalid combination is configured, the ErrInvalidValue is printed for now.
It is not accurate message and will mislead users.

To fix it, this patch prints accurate message with ErrGeneric.
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 17, 2019
@knative-prow-robot knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 17, 2019

@knative-prow-robot knative-prow-robot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nak3: 0 warnings.

Details

In response to this:

Proposed Changes

This PR is basically same idea with the fix of #5382.

When invalid combination is configured, the ErrInvalidValue is printed for now.
It is not accurate message and will mislead users.

To fix it, this patch prints accurate message with ErrGeneric.

BEFORE:

invalid value: true: spec.traffic[0].latestRevision

AFTER:

May not set revisionName "hello-example-dk7nd" when latestRevision is true: spec.traffic[0].latestRevision

for following combination.

 traffic:
 - latestRevision: true
   revisionName: hello-example-dk7nd
   percent: 100

Also, ref: knative/pkg#638

/lint

Release Note

NONE

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added the area/API API objects and controllers label Sep 17, 2019

@markusthoemmes markusthoemmes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I personally like it a lot more than what we currently have.

/assign @dgerd

Comment thread pkg/apis/serving/v1/route_validation.go Outdated
// The senses for whether to pin to a particular revision or
// float forward to the latest revision must match.
return apis.ErrInvalidValue(lr, "latestRevision")
return apis.ErrGeneric(fmt.Sprintf("May not set revisionName %q when latestRevision is %t", tt.RevisionName, lr), "latestRevision")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Errors should always start with a lowercase character (I can't my source for it 😂, maybe you just trust me?). It's to aid readability on composed errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the log should always start with a lowercase character (I also cannot find the source, but it should be.) Thank you. Updated.

@vagababov vagababov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 17, 2019

@markusthoemmes markusthoemmes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm
/approve

@nak3

nak3 commented Sep 20, 2019

Copy link
Copy Markdown
Contributor Author

/assign @dgerd

@dgerd

dgerd commented Oct 3, 2019

Copy link
Copy Markdown

/approve

@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgerd, markusthoemmes, nak3, vagababov

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

The pull request process is described here

Details 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2019
@knative-prow-robot
knative-prow-robot merged commit 0567a74 into knative:master Oct 3, 2019
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. area/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

6 participants