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

Errors with Caddy 2.2.1 #2

Closed
deadlysnek opened this issue Oct 24, 2020 · 4 comments · Fixed by #3
Closed

Errors with Caddy 2.2.1 #2

deadlysnek opened this issue Oct 24, 2020 · 4 comments · Fixed by #3

Comments

@deadlysnek
Copy link

deadlysnek commented Oct 24, 2020

I'm compiling Caddy 2.2.1 with xcaddy using Go 1.14.4 on Ubuntu 20.04.1 LTS

xcaddy build \
    --with github.com/abiosoft/caddy-json-schema \
    --with github.com/caddy-dns/cloudflare

Caddy builds and runs fine, executing caddy json-schema --vscode gives me this message

panic: reflect: call of reflect.Value.Type on zero Value
 
goroutine 1 [running]:
reflect.Value.Type(0x0, 0x0, 0x0, 0xc0006d7130, 0xc00073ee78)
        reflect/value.go:1872 +0x183
github.com/abiosoft/caddy-json-schema.(*Interface).populate(0xc0008750e0, 0x0, 0x0)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:143 +0xef
github.com/abiosoft/caddy-json-schema.(*Interface).populate(0xc000875050, 0x148df40, 0xc0005c5860)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:132 +0x38e
github.com/abiosoft/caddy-json-schema.(*Interface).populateStruct(0xc000874e10, 0x1a7a5a0, 0x15fbd00)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:186 +0xd4a
github.com/abiosoft/caddy-json-schema.(*Interface).populate(0xc000874e10, 0x15fbd00, 0xc0005305c0)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:120 +0x2ac
github.com/abiosoft/caddy-json-schema.(*Interface).populate(0xc000874d80, 0x1488a80, 0xc0005c5840)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:132 +0x38e
github.com/abiosoft/caddy-json-schema.(*Interface).populateStruct(0xc00073fc88, 0x1a7a5a0, 0x1634e60)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:186 +0xd4a
github.com/abiosoft/caddy-json-schema.(*Interface).populate(0xc00073fc88, 0x1634e60, 0xc0004142a0)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:120 +0x2ac
github.com/abiosoft/caddy-json-schema.(*Interface).populate(0xc00073fc88, 0x15a28c0, 0xc000115bc0)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/interface.go:124 +0x14e
github.com/abiosoft/caddy-json-schema.generateSchema(0x0, 0x0)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/schema_util.go:51 +0x159
github.com/abiosoft/caddy-json-schema.run(0xc000115a40, 0xc00003a1a0, 0x1, 0x1)
        github.com/abiosoft/caddy-json-schema@v0.0.0-20200527180432-2d0cb96ed8ea/command.go:67 +0x3d
github.com/caddyserver/caddy/v2/cmd.Main()
        github.com/caddyserver/caddy/v2@v2.2.1/cmd/main.go:85 +0x239
main.main()
        caddy/main.go:13 +0x20
@rayjlinden
Copy link

I just got this same error. I see the issue was logged in October. Has anyone looked at this?

@ghostwheel42
Copy link
Contributor

Hi. It's caused by passed to f.populate() and is caused by the Outputs []interface{} definition in http.handler.map.
A quick fix would be to add this to interface.go:

func (f *Interface) populate(s interface{}) {

    if s == nil {
        f.Type = "string"
        return
    }

But I don't see how multiple types can be added to the json schema: "type": ["string", "null"] would be better.

@a-r-db
Copy link

a-r-db commented Mar 6, 2021

@ghostwheel42 Thanks so much.
I have not tested all the functionality.
I just needed to get this module working.

$ caddy json-schema --vscode
json-schema .vscode/caddy_schema.json written.
json-schema .vscode/settings.json written.

@abiosoft
Copy link
Owner

Thanks @ghostwheel42 for this. Better late than never :)

Everything should be fine now and the broken documentation has also been fixed for standard and third party plugins.

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

Successfully merging a pull request may close this issue.

5 participants