{"record":{"id":"5b6c7d5545589aa2","repo":"caddyserver/caddy","slug":"s-d-parsed-s-as-a-site-address-but-it-is-a","errorCode":null,"errorMessage":"%s:%d: parsed '%s' as a site address, but it is a known directive; directives must appear in a site block","messagePattern":"(.+?):(.+?): parsed '(.+?)' as a site address, but it is a known directive; directives must appear in a site block","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"caddyconfig/httpcaddyfile/httptype.go","lineNumber":74,"sourceCode":"\n// Setup makes a config from the tokens.\nfunc (st ServerType) Setup(\n\tinputServerBlocks []caddyfile.ServerBlock,\n\toptions map[string]any,\n) (*caddy.Config, []caddyconfig.Warning, error) {\n\tvar warnings []caddyconfig.Warning\n\tgc := counter{new(int)}\n\tstate := make(map[string]any)\n\n\t// load all the server blocks and associate them with a \"pile\" of config values\n\toriginalServerBlocks := make([]serverBlock, 0, len(inputServerBlocks))\n\tfor _, sblock := range inputServerBlocks {\n\t\tfor j, k := range sblock.Keys {\n\t\t\tif j == 0 && strings.HasPrefix(k.Text, \"@\") {\n\t\t\t\treturn nil, warnings, fmt.Errorf(\"%s:%d: cannot define a matcher outside of a site block: '%s'\", k.File, k.Line, k.Text)\n\t\t\t}\n\t\t\tif _, ok := registeredDirectives[k.Text]; ok {\n\t\t\t\treturn nil, warnings, fmt.Errorf(\"%s:%d: parsed '%s' as a site address, but it is a known directive; directives must appear in a site block\", k.File, k.Line, k.Text)\n\t\t\t}\n\t\t}\n\t\toriginalServerBlocks = append(originalServerBlocks, serverBlock{\n\t\t\tblock: sblock,\n\t\t\tpile:  make(map[string][]ConfigValue),\n\t\t})\n\t}\n\n\t// apply any global options\n\tvar err error\n\toriginalServerBlocks, err = st.evaluateGlobalOptionsBlock(originalServerBlocks, options)\n\tif err != nil {\n\t\treturn nil, warnings, err\n\t}\n\n\t// this will replace both static and user-defined placeholder shorthands\n\t// with actual identifiers used by Caddy\n\treplacer := NewShorthandReplacer()","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/caddyconfig/httpcaddyfile/httptype.go#L56-L92","documentation":"Error \"%s:%d: parsed '%s' as a site address, but it is a known directive; directives must appear in a site block\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at caddyconfig/httpcaddyfile/httptype.go:74 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Place the directive inside a site block instead of using it as a site address.","If you intended a site address, rename it so it does not collide with a known directive name."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}