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

Required field in JSON schema that can be oneOf: string, null, not handled correctly #13004

Open
TylerGillson opened this issue May 6, 2024 · 3 comments

Comments

@TylerGillson
Copy link

Given the following JSON schema:

{
    "title": "dummy schema",
    "$ref": "#/definitions/All",
    "definitions": {
        "All": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "dummy": {
                    "$ref": "#/definitions/Dummy"
                }
            }
        },
        "Dummy": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "irsaRole": {
                    "oneOf": [
                        {
                            "type": "string",
                            "pattern": "^arn:aws:iam:.+$",
                            "minLength": 20
                        },
                        {
                            "type": "null"
                        }
                    ]
                }
            },
            "required": [
                "irsaRole"
            ],
            "title": "Dummy"
        }
    }
}

And the following values.yaml:

dummy:
  irsaRole: null

I get a validation error:

Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
dummy:
- dummy: irsaRole is required

What I expected: chart validation should pass.

Examples from jsonschemavalidator.net:

Output of helm version:

version.BuildInfo{Version:"v3.14.4", GitCommit:"81c902a123462fd4052bc5e9aa9c513c4c8fc142", GitTreeState:"clean", GoVersion:"go1.22.2"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:13:27Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"darwin/arm64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"28", GitVersion:"v1.28.3", GitCommit:"a8a1abc25cad87333840cd7d54be2efaf31a3177", GitTreeState:"clean", BuildDate:"2023-10-18T11:33:18Z", GoVersion:"go1.20.10", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):
AWS

@gjenkins8 gjenkins8 added bug Categorizes issue or PR as related to a bug. question/support and removed bug Categorizes issue or PR as related to a bug. labels May 12, 2024
@gjenkins8
Copy link
Contributor

Can you create a more detailed replication example please. From a quick hack up using your jsonschema, if I use the values:

---
dummy:
  irsaRole: "foo"

I get the error:

 $ helm template .
Error: values don't meet the specifications of the schema(s) in the following chart(s):
jschema:
- dummy.irsaRole: Must validate one and only one schema (oneOf)
- dummy.irsaRole: String length must be greater than or equal to 20
- dummy.irsaRole: Does not match pattern '^arn:aws:iam:.+$'

Is there a subchart 'dummy'?

@TylerGillson
Copy link
Author

@gjenkins8 apologies for the non-reproducible example. The real source for this issue is the k8gb Helm chart. I can also try to get you a more minimal example if you'd prefer.

@TylerGillson
Copy link
Author

Steps to reproduce:

❯ git clone https://github.com/k8gb-io/k8gb && cd k8gb/chart/k8gb
❯ helm dependency build
❯ sed -i '' 's|arn:aws:iam::111111:role/external-dns|null|g' values.yaml
❯ helm install k8gb . --create-namespace -f values.yaml
Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
k8gb:
- route53: irsaRole is required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants