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

panic: reflect: call of reflect.flag.mustBeExported on zero Value #75

Open
lnxbil opened this issue Feb 7, 2020 · 0 comments
Open

panic: reflect: call of reflect.flag.mustBeExported on zero Value #75

lnxbil opened this issue Feb 7, 2020 · 0 comments

Comments

@lnxbil
Copy link

lnxbil commented Feb 7, 2020

Hi everyone,

I'm in the progress of migrating a project from perl to go and have problems with a previously working JSON schema file with conflate. I first tried gojsonschema and the schema was valid there, but had no default value integration, so I turned to conflate.

I ran into a panic (with my code and the conflate binary)

$ ~/go/bin/conflate -data testdata/data.yaml -schema schema/data.schema.json -validate -defaults
panic: reflect: call of reflect.flag.mustBeExported on zero Value

goroutine 1 [running]:
reflect.flag.mustBeExportedSlow(0x0)
        /usr/local/Cellar/go/1.13.4/libexec/src/reflect/value.go:222 +0xad
reflect.flag.mustBeExported(...)
        /usr/local/Cellar/go/1.13.4/libexec/src/reflect/value.go:216
reflect.Value.Set(0x147fbe0, 0xc000267c50, 0x194, 0x0, 0x0, 0x0)
        /usr/local/Cellar/go/1.13.4/libexec/src/reflect/value.go:1532 +0x56
github.com/miracl/conflate.applyDefaultsRecursive(0xc00026a850, 0xb, 0x14816e0, 0xc0001dab10, 0x1453340, 0xc000267c50, 0x14816e0, 0xc0001dade0, 0x0, 0x0)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:208 +0xa1f
github.com/miracl/conflate.applyObjectDefaults(0xc00026a780, 0x6, 0x14816e0, 0xc0001dab10, 0x14816e0, 0xc0001da0f0, 0xc0001dad80, 0x0, 0x0)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:247 +0x294
github.com/miracl/conflate.applyDefaultsRecursive(0xc00026a780, 0x6, 0x14816e0, 0xc0001dab10, 0x1453340, 0xc0002678e0, 0x14816e0, 0xc0001dad80, 0x0, 0x0)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:215 +0x959
github.com/miracl/conflate.applyObjectDefaults(0x150ad41, 0x1, 0x14816e0, 0xc0001dab10, 0x14816e0, 0xc0001da060, 0xc0001dab10, 0x10bd, 0x12bd)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:247 +0x294
github.com/miracl/conflate.applyDefaultsRecursive(0x150ad41, 0x1, 0x14816e0, 0xc0001dab10, 0x1453340, 0xc0000ba980, 0x14816e0, 0xc0001dab10, 0xc000188417, 0x0)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:215 +0x959
github.com/miracl/conflate.applyDefaults(0x1453340, 0xc0000ba980, 0x14816e0, 0xc0001dab10, 0x0, 0x0)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:160 +0x6c
github.com/miracl/conflate.(*Schema).ApplyDefaults(0xc000267820, 0x1453340, 0xc0000ba980, 0x0, 0x0)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/schema.go:77 +0x54
github.com/miracl/conflate.(*Conflate).ApplyDefaults(...)
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/conflate.go:112
main.main()
        /Users/andreas/go/pkg/mod/github.com/miracl/conflate@v1.1.0/conflate/main.go:72 +0x7f2

with this schema properties:

...
"host" : {
          "type": [ "string", "null" ],
          "description": "Hostname",
          "pattern": "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])$",
          "default": null
        },
...

If I change it to use only string (and allow the empty string in the validation), it works:

"host" : {
          "type": "string",
          "description": "Hostname",
          "pattern": "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9]|)$",
          "default": ""
        },

It's not a big limitation, but I need to change my previously working schema file in order to get it to work with conflate.

Is this a bug worth noting?

Best,
Andreas

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

No branches or pull requests

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy