Skip to content

caddy validate does not check if the Caddyfile exists #5612

@p0358

Description

@p0358

I think this is pretty self-explanatory:

$ caddy adapt
Error: input file required when there is no Caddyfile in current directory (use --config flag)
$ caddy validate
Error: decoding config: unexpected end of JSON input

The validate command, unlike adapt misses check that assesses the file even exists in the first place. With that, the user may assume the file was read and that they have some syntax error they'll be endlessly looking for, even though that's not the problem...

Check for adapt exists here:

caddy/cmd/commandfuncs.go

Lines 439 to 442 in dfe17c3

if adaptCmdInputFlag == "" {
return caddy.ExitCodeFailedStartup,
fmt.Errorf("input file required when there is no Caddyfile in current directory (use --config flag)")
}

Missing in this func:

func cmdValidateConfig(fl Flags) (int, error) {

Should be simple fix for someone who already has a dev environment setup to test it out before committing (hence I'm creating an issue and not PR)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions