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

Strict unmarshalling should be case-sensitive #15

Open
martina-if opened this issue Apr 26, 2019 · 20 comments
Open

Strict unmarshalling should be case-sensitive #15

martina-if opened this issue Apr 26, 2019 · 20 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.

Comments

@martina-if
Copy link

Using yaml.UnmarshalStrict(...) compares keys in a case insensitive way.

I would expect it to do case sensitive comparisons of key names so that if I define a key in my schema called somethingGreat, a key in a yaml file called somethingGREat wouldn't match, and the unmarshal would fail with the error unknown field "somethingGREat".

@errordeveloper
Copy link

cc @dims @sttts @neolit123

@neolit123
Copy link
Member

i will verify this locally.
seems like something we want to fix.

@neolit123
Copy link
Member

/kind bug
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Apr 26, 2019
@dims
Copy link
Member

dims commented Apr 26, 2019

/assign @neolit123

@martina-if
Copy link
Author

How to reproduce it:


import (
	"fmt"
	// yaml "gopkg.in/yaml.v2"
	yaml "sigs.k8s.io/yaml"
)

func main() {

	type T struct {
		SomethingGreat int `yaml:"SomethingGreat,omitempty"`
	}
	var t T

	// Correct letter case
	if err := yaml.UnmarshalStrict([]byte("SomethingGreat: 1"), &t); err != nil {
		fmt.Printf("ERROR: %v\n", err)
	} else {
		fmt.Printf("Correctly parsed: %+v\n", t)
	}

	// Incorrect letter case
	if err := yaml.UnmarshalStrict([]byte("SomethingGREat: 2"), &t); err != nil {
		fmt.Printf("ERROR: %v\n", err)
	} else {
		fmt.Printf("Correctly parsed: %+v\n", t)
	}
}

Produces:

Correctly parsed: {SomethingGreat:1}
Correctly parsed: {SomethingGreat:2}

@errordeveloper
Copy link

So with yaml "gopkg.in/yaml.v2" it does actually fail:

Correctly parsed: {SomethingGreat:1}
ERROR: yaml: unmarshal errors:
  line 1: field SomethingGREat not found in type main.T

I wonder what is going on here...

@neolit123
Copy link
Member

@martina-if @errordeveloper
see this PR in flight:
#19

Correctly parsed: {SomethingGreat:1}
ERROR: main.T.ReadObject: found unknown field: SomethingGREat, error found in #1
0 byte of ...|hingGREat":2}|..., bigger context ...|{"SomethingGREat":2}|...

@martina-if
Copy link
Author

Hi @neolit123, thanks for the link to the PR! Do you need a review from our side?

@neolit123
Copy link
Member

sure, go ahead.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 11, 2019
@errordeveloper
Copy link

errordeveloper commented Aug 11, 2019 via email

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 11, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 9, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 9, 2019
@errordeveloper
Copy link

errordeveloper commented Dec 10, 2019 via email

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Dec 10, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 9, 2020
@errordeveloper
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 10, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 8, 2020
@errordeveloper
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 8, 2020
@errordeveloper
Copy link

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Jun 8, 2020
@neolit123
Copy link
Member

we faced this recently again here:
kubernetes/kubeadm#2167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants