{"record":{"id":"a4ac91cbb2248b7e","repo":"caddyserver/caddy","slug":"parsing-key-v","errorCode":null,"errorMessage":"parsing key: %v","messagePattern":"parsing key: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"caddyconfig/httpcaddyfile/addresses.go","lineNumber":100,"sourceCode":") (map[string]map[string][]serverBlock, error) {\n\taddrToProtocolToServerBlocks := map[string]map[string][]serverBlock{}\n\n\ttype keyWithParsedKey struct {\n\t\tkey       caddyfile.Token\n\t\tparsedKey Address\n\t}\n\n\tfor i, sblock := range originalServerBlocks {\n\t\t// within a server block, we need to map all the listener addresses\n\t\t// implied by the server block to the keys of the server block which\n\t\t// will be served by them; this has the effect of treating each\n\t\t// key of a server block as its own, but without having to repeat its\n\t\t// contents in cases where multiple keys really can be served together\n\t\taddrToProtocolToKeyWithParsedKeys := map[string]map[string][]keyWithParsedKey{}\n\t\tfor j, key := range sblock.block.Keys {\n\t\t\tparsedKey, err := ParseAddress(key.Text)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing key: %v\", err)\n\t\t\t}\n\t\t\tparsedKey = parsedKey.Normalize()\n\n\t\t\t// a key can have multiple listener addresses if there are multiple\n\t\t\t// arguments to the 'bind' directive (although they will all have\n\t\t\t// the same port, since the port is defined by the key or is implicit\n\t\t\t// through automatic HTTPS)\n\t\t\tlisteners, err := st.listenersForServerBlockAddress(sblock, parsedKey, options)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"server block %d, key %d (%s): determining listener address: %v\", i, j, key.Text, err)\n\t\t\t}\n\n\t\t\t// associate this key with its protocols and each listener address served with them\n\t\t\tkwpk := keyWithParsedKey{key, parsedKey}\n\t\t\tfor addr, protocols := range listeners {\n\t\t\t\tprotocolToKeyWithParsedKeys, ok := addrToProtocolToKeyWithParsedKeys[addr]\n\t\t\t\tif !ok {\n\t\t\t\t\tprotocolToKeyWithParsedKeys = map[string][]keyWithParsedKey{}","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/caddyconfig/httpcaddyfile/addresses.go#L82-L118","documentation":"While mapping server-block keys to listeners, a site address key failed ParseAddress. This validates the site label syntax (scheme://host:port/path) before normalization; any parse failure is wrapped as 'parsing key'.","triggerScenarios":"A Caddyfile site block key is malformed: bad host characters, invalid port (non-numeric), wrong scheme:// placement, or a placeholder/variable that ParseAddress cannot interpret as a concrete address.","commonSituations":"Typos like 'example.com:' (empty port), 'https://example.com:notaport', or using placeholders like {$SITE} when the environment variable is unset (leaving an unparseable key).","solutions":["Read the wrapped parse error for the exact reason, then fix the key text on the site block line","If using {$ENV} placeholders in site addresses, verify the variables are set in Caddy's environment","Validate with `caddy adapt --config Caddyfile` to iterate quickly","Check the Caddyfile site-address syntax docs for scheme/host/port/path combinations"],"exampleFix":"# before\nhttps://example.com:notaport {\n}\n# after\nhttps://example.com:8443 {\n}","handlingStrategy":"validation","validationCode":"for _, key := range blockKeys {\n    if _, err := httpcaddyfile.ParseAddress(key); err != nil {\n        return fmt.Errorf(\"bad site address %q: %w\", key, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set every {$ENV} placeholder used in site labels before starting Caddy","Keep site labels to scheme://host:port form","Adapt configs in CI with env vars present"],"tags":["caddyfile","site-address","parse"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}