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

Create secret with invalid base64 data gives unhelpful error message #10309

Closed
erictune opened this issue Jun 24, 2015 · 4 comments
Closed

Create secret with invalid base64 data gives unhelpful error message #10309

erictune opened this issue Jun 24, 2015 · 4 comments
Labels
area/kubectl priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@erictune
Copy link
Member

This works:
kubectl create -f examples/secrets/secret.yaml

But, modify one of the base64 encoded fields to be invalid (such as by adding an extra = at the end), and try again. You get this error message which is completely unhelpful:
error: no objects passed to create.

@erictune erictune added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jun 24, 2015
@erictune erictune changed the title Create secret with invalid base64 data results gives unhelpful error message Create secret with invalid base64 data gives unhelpful error message Jun 24, 2015
@mbforbes mbforbes added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Jun 24, 2015
@feihujiang
Copy link
Contributor

I tried "kubectl create -f examples/secrets/secret.yaml" in version 19+,
the error message is:
error: unable to load file "examples/secrets/secret.yaml": unable to load "examples/secrets/secret.yaml": illegal base64 data at input byte 16
error: no objects passed to create

@erictune Is this error message helpful? Or do we need to improve it?

@adalinesimonian
Copy link

The error for invalid keys is equally confusing:

$ kubectl create -f secret.yml
The Secret "mysecret" is invalid:
* data[cookieSecret]: invalid value 'cookieSecret': must have at most 253 characters and match regex \.?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*

This makes it seem as though the base64 data is invalid because it reads invalid value instead of invalid key. Certainly sent me off on a wild goose chase until I read up on the restrictions for the keys.

@nikhita
Copy link
Member

nikhita commented Mar 21, 2017

I think this issue can be closed now.

  1. As @feihujiang mentioned, the error gives a helpful message that there is invalid base64 data (along with the position). If there is any improvement required to the error message, I'd like to work on it!

  2. For invalid keys, the error message is now:

# secrets "mysecret" was not valid:
# * data[user*name]: Invalid value: "user*name": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name',  or 'KEY_NAME',  or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')

Now it clearly mentions that the key is invalid and not the value. Ref: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L281

@erictune
Copy link
Member Author

Thanks for verifying this is fixed, @nikinath! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

7 participants