{"record":{"id":"a70456f35c2bc249","repo":"crowdsecurity/crowdsec","slug":"invalid-dsn-s-for-s3-source","errorCode":null,"errorMessage":"invalid DSN %s for S3 source","messagePattern":"invalid DSN (.+?) for S3 source","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/s3/config.go","lineNumber":271,"sourceCode":"\ts.Config.Mode = configuration.CAT_MODE\n\ts.Config.UniqueId = uuid\n\n\tpathParts := strings.Split(args[0], \"/\")\n\ts.logger.Debugf(\"pathParts: %v\", pathParts)\n\n\t// FIXME: handle s3://bucket/\n\tif len(pathParts) == 1 {\n\t\ts.Config.BucketName = pathParts[0]\n\t\ts.Config.Prefix = \"\"\n\t} else if len(pathParts) > 1 {\n\t\ts.Config.BucketName = pathParts[0]\n\t\tif args[0][len(args[0])-1] == '/' {\n\t\t\ts.Config.Prefix = strings.Join(pathParts[1:], \"/\")\n\t\t} else {\n\t\t\ts.Config.Key = strings.Join(pathParts[1:], \"/\")\n\t\t}\n\t} else {\n\t\treturn fmt.Errorf(\"invalid DSN %s for S3 source\", dsn)\n\t}\n\n\tclient, err := s.newS3Client(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.s3Client = client\n\n\treturn nil\n}\n","sourceCodeStart":253,"sourceCodeEnd":283,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/s3/config.go#L253-L283","documentation":"After splitting the s3:// DSN path on '/', the code expects one part (bucket only) or more (bucket plus prefix/key); this branch is unreachable in practice (empty path is caught earlier) and guards against an unclassifiable path shape.","triggerScenarios":"Calling ConfigureByDSN with a DSN lacking a bucket or path, e.g. `s3://` with no further parts, or a malformed scheme/path so the parsing branch never matches.","commonSituations":"Misconfigured acquis.yaml entries; users omitting the bucket; extra characters or wrong scheme; trailing-slash expectations not met.","solutions":["Specify a bucket in the DSN, e.g. s3://my-bucket/prefix","Use s3://bucket to poll the whole bucket"],"exampleFix":"// before\ns3://\n// after\ns3://my-logs-bucket/cloudtrail/AWSLogs/","handlingStrategy":"validation","validationCode":"u, err := url.Parse(dsn)\nif err != nil || u.Host == \"\" || strings.Trim(u.Path, \"/\") == \"\" {\n    return fmt.Errorf(\"DSN must be s3://<bucket>/<prefix-or-key>, got %q\", dsn)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave the bucket or path empty in s3:// DSNs.","Template DSNs from variables with non-empty checks.","Validate acquis.yaml entries before restart."],"tags":["configuration","s3","acquisition","dsn"],"backgroundTag":"invalid-url-format","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"}