{"record":{"id":"33d5cec1d70fecad","repo":"crowdsecurity/crowdsec","slug":"path-must-start-with","errorCode":null,"errorMessage":"path must start with /","messagePattern":"path must start with /","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/http/config.go","lineNumber":100,"sourceCode":"\nfunc (s *Source) UnmarshalConfig(yamlConfig []byte) error {\n\tcfg, err := ConfigurationFromYAML(yamlConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.Config = cfg\n\n\treturn nil\n}\n\nfunc (c *Configuration) Validate() error {\n\tif c.ListenAddr == \"\" && c.ListenSocket == \"\" {\n\t\treturn errors.New(\"listen_addr or listen_socket is required\")\n\t}\n\n\tif c.Path[0] != '/' {\n\t\treturn errors.New(\"path must start with /\")\n\t}\n\n\tswitch c.AuthType {\n\tcase \"basic_auth\":\n\t\tbaseErr := \"basic_auth is selected, but\"\n\t\tif c.BasicAuth == nil {\n\t\t\treturn errors.New(baseErr + \" basic_auth is not provided\")\n\t\t}\n\n\t\tif c.BasicAuth.Username == \"\" {\n\t\t\treturn errors.New(baseErr + \" username is not provided\")\n\t\t}\n\n\t\tif c.BasicAuth.Password == \"\" {\n\t\t\treturn errors.New(baseErr + \" password is not provided\")\n\t\t}\n\tcase \"headers\":\n\t\tif c.Headers == nil {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/http/config.go#L82-L118","documentation":"CrowdSec's HTTP acquisition module requires the `path` config field (the URL path of the endpoint to poll/POST to) to be an absolute path beginning with '/'. Configuration.Validate() checks c.Path[0] != '/' and rejects anything else before the datasource is ever started. This is a static config validation error, not a runtime failure.","triggerScenarios":"Configure an http datasource whose `path` field is empty, missing its leading slash (e.g. `path: api/events`), or is a full URL instead of a path (e.g. `path: https://host/api`). Any call to Configuration.Validate() with such a config returns this error.","commonSituations":"Users paste a full URL into `path` when only the path portion belongs there; YAML values like `path: metrics` copied from examples that changed; empty string when the key exists but the value was removed; interpolation of an env var that resolves to something without a leading slash.","solutions":["Add a leading slash to the path value: `path: /api/events`.","If you put a full URL in `path`, keep only the path portion and move scheme/host into the base URL/listen config fields.","If the value comes from an env var or template, ensure the resolved value starts with '/'.","If `path` is optional for your setup, omit the key rather than setting it to an empty string (check the module's defaults)."],"exampleFix":"// before (config.yaml)\nsource: http\npath: api/events\n\n// after\nsource: http\npath: /api/events","handlingStrategy":"validation","validationCode":"func validHTTPPath(p string) bool { return strings.HasPrefix(p, \"/\") }\nif !validHTTPPath(cfg.Path) { return fmt.Errorf(\"path %q must start with /\", cfg.Path) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write `path` values with a leading slash in datasource configs.","Never place a full URL in `path`; keep scheme/host out of it.","Validate config in CI with a lint step before deploying crowdsec.","When interpolating env vars into `path`, assert the result starts with '/'."],"tags":["config","validation","http","crowdsec"],"backgroundTag":"invalid-config-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}