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

Disallowing unknown fields doesn't work when decoding into an object in the JSON serializer #104661

Closed
luxas opened this issue Aug 30, 2021 · 12 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@luxas
Copy link
Member

luxas commented Aug 30, 2021

What happened:

Although the Strict mode (i.e. what should disallow unknown and duplicate fields) is enabled in the json.Serializer; unknown fields in serialized data doesn't yield any error when specifying the into parameter of the Decode( function.

What you expected to happen:

Disallowing unknown fields should yield errors when there are fields in serialized data that do not map to a struct field, regardless of decoding type (into or non-into)

How to reproduce it (as minimally and precisely as possible):

In this codepath there is no strict checking like here. The "sanitation" method linked in the latter case should be run for both the into and non-into cases, and an unit test should be added.

Anything else we need to know?:

I can send a PR for this :)

/sig apimachinery
cc @dims @sttts FYI

@luxas luxas added the kind/bug Categorizes issue or PR as related to a bug. label Aug 30, 2021
@k8s-ci-robot
Copy link
Contributor

@luxas: The label(s) sig/apimachinery cannot be applied, because the repository doesn't have them.

In response to this:

What happened: Although the Strict mode (i.e. what should disallow unknown and duplicate fields) is enabled in the json.Serializer; unknown fields in serialized data doesn't yield any error when specifying the into parameter of the Decode( function.

What you expected to happen: Disallowing unknown fields should yield errors when there are fields in serialized data that do not map to a struct field, regardless of decoding type (into or non-into)

How to reproduce it (as minimally and precisely as possible):

In this codepath there is no strict checking like here. The "sanitation" method linked in the latter case should be run for both the into and non-into cases, and an unit test should be added.

Anything else we need to know?:

I can send a PR for this :)

/sig apimachinery
cc @dims @sttts FYI

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.

@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 30, 2021
@luxas
Copy link
Member Author

luxas commented Aug 30, 2021

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 30, 2021
@luxas
Copy link
Member Author

luxas commented Aug 30, 2021

/assign

@dims
Copy link
Member

dims commented Aug 30, 2021

cc @liggitt

@fedebongio
Copy link
Contributor

Thank you @luxas for taking this one!
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 31, 2021
@luxas
Copy link
Member Author

luxas commented Sep 1, 2021

Cool, I'll send a PR is a couple of days 😄

@luxas
Copy link
Member Author

luxas commented Sep 4, 2021

Argh, didn't get to it this week, and I'm on vacation next week, but I'll get to it after that.

@aaqaishtyaq
Copy link

Hey @luxasm, I would like to contribute to Kubernetes. Let me know if I can take this up.

@luxas
Copy link
Member Author

luxas commented Sep 13, 2021

Absolutely, thanks for volunteering! 🥇

Let's chat on the Kubernetes Slack (join at https://slack.k8s.io/ if you're not already there) and if needed, hop on a short video call to get you going with this task? I'm @luxas on the Kubernetes Slack as well, please send me a message when you're there.

aaqaishtyaq added a commit to aaqaishtyaq/kubernetes that referenced this issue Nov 4, 2021
fixes: kubernetes#104661

- add `Strict` mode check for `into` parameter of the Decode function
  in json.Serializer

Signed-off-by: Aaqa Ishtyaq <aaqaishtyaq@gmail.com>
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Dec 12, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Jan 11, 2022
@liggitt
Copy link
Member

liggitt commented Jan 25, 2022

resolved by #105916

@liggitt liggitt closed this as completed Jan 25, 2022
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/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants