Caddy: JSON configuration validation fails with @id field

Created on 24 Mar 2020  路  6Comments  路  Source: caddyserver/caddy

caddy validate crashes when a JSON with the @id field is passed to it.

command : caddy validate --config caddy.json


JSON configuration

{
  "apps" : {
    "http" : {
      "servers" : {
        "caddy.test.shinenelson.xyz" : {
          "listen" : [
            ":80",
            ":443"
          ],
          "routes" : [
            {
              "group" : "shine",
              "@id" : "shine",
              "match" : [
                {
                  "host" : [
                    "*.shine.caddy.test.shinenelson.xyz"
                  ]
                }
              ],
              "handle": [
                 {
                  "@id" : "proxy_shine",
                  "handler" : "reverse_proxy",
                  "upstreams" : [
                    {
                      "dial" : "localhost"
                    },
                    {
                      "dial" : "localhost"
                    }
                  ]
                }
              ],
              "terminal" : true
            }
          ]
        }
      }
    }
  }
}

Error : validate: loading app modules: module name 'http': decoding module config: http: json: unknown field "@id"

The configuration works fine if I loaded it to a caddy server. I'm able to manipulate the @id via the API as well.

bug needs tests

Most helpful comment

@mholt I know that you work on this full time. Even then, wouldn't you have other areas to focus on than just looking at bug reports that come in? I mean, I understand that this is also part of the job. It's just that I haven't seen such fast turn-around times in open-source. I mean, I'd understand if it was once, but this is the second time with me ( which gives me the impression that it is every time; and I'd like to keep it that way ).

I really wanted to sponsor you ( at least a one-time donation ) when this issue closed in under an hour ( again ). I literally exclaimed that out loud. The problem is that I don't earn any money right now. I wish I had.

All 6 comments

Thanks for the report! I was able to reproduce this quite easily thanks to the full, unredacted config. It's due to the spaces around the : in your config and my regex that didn't account for that. Fix incoming.

@mholt I have no idea how you're doing this, but your turn-around time with issues are simply mind-blowing. You're a true rockstar! :rocket:

@mholt tagging with needs tests cause we should probably add a test case to cover this at some point :smile:

@shinenelson I work on this full time, many thanks to corporate and individual sponsors! Not a rockstar though -- just a humble dev doing his thing.

@francislavoie To be honest, the whole code base needs tests...

@mholt I know that you work on this full time. Even then, wouldn't you have other areas to focus on than just looking at bug reports that come in? I mean, I understand that this is also part of the job. It's just that I haven't seen such fast turn-around times in open-source. I mean, I'd understand if it was once, but this is the second time with me ( which gives me the impression that it is every time; and I'd like to keep it that way ).

I really wanted to sponsor you ( at least a one-time donation ) when this issue closed in under an hour ( again ). I literally exclaimed that out loud. The problem is that I don't earn any money right now. I wish I had.

Thanks, that's really nice. The bugs you reported happened to be easy to fix, and I was at my desk when they came in. It's not always like that, though...

No pressure to sponsor, take care of your own situation first.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mschneider82 picture mschneider82  路  3Comments

PhilmacFLy picture PhilmacFLy  路  3Comments

whs picture whs  路  3Comments

billop picture billop  路  3Comments

wayneashleyberry picture wayneashleyberry  路  3Comments