{"record":{"id":"6e394c311ce9172d","repo":"crowdsecurity/crowdsec","slug":"unable-to-parse-target-s-w","errorCode":null,"errorMessage":"unable to parse target '%s': %w","messagePattern":"unable to parse target '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest_item.go","lineNumber":391,"sourceCode":"\t}\n\n\t// wait for the appsec port to be available\n\tif _, err = IsAlive(ctx, t.AppSecHost); err != nil {\n\t\tcrowdsecLog, err2 := os.ReadFile(crowdsecLogFile)\n\t\tif err2 != nil {\n\t\t\tlog.Errorf(\"unable to read crowdsec log file '%s': %s\", crowdsecLogFile, err)\n\t\t} else {\n\t\t\tlog.Errorf(\"crowdsec log file '%s'\", crowdsecLogFile)\n\t\t\tlog.Errorf(\"%s\\n\", string(crowdsecLog))\n\t\t}\n\n\t\treturn fmt.Errorf(\"appsec is down: %w\", err)\n\t}\n\n\t// check if the target is available\n\tnucleiTargetParsedURL, err := url.Parse(t.NucleiTargetHost)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to parse target '%s': %w\", t.NucleiTargetHost, err)\n\t}\n\n\tnucleiTargetHost := nucleiTargetParsedURL.Host\n\tif _, err = IsAlive(ctx, nucleiTargetHost); err != nil {\n\t\treturn fmt.Errorf(\"target is down: %w\", err)\n\t}\n\n\tnucleiConfig := NucleiConfig{\n\t\tPath:      \"nuclei\",\n\t\tOutputDir: t.RuntimePath,\n\t\tCmdLineOptions: []string{\n\t\t\t\"-ev\",    // allow variables from environment\n\t\t\t\"-nc\",    // no colors in output\n\t\t\t\"-dresp\", // dump response\n\t\t\t\"-j\",     // json output\n\t\t},\n\t}\n","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest_item.go#L373-L409","documentation":"url.Parse rejected the nuclei target host (NucleiTargetHost) while preparing a hubtest appsec test run with a nuclei template. The configured target URL for the test is malformed (bad scheme, port, or percent-encoding), so the nuclei scan cannot proceed.","triggerScenarios":"t.NucleiTargetHost in the test's config is empty, malformed (e.g. missing scheme or stray characters), or contains spaces/newlines so url.Parse rejects it.","commonSituations":"Test config file typo in the nuclei target host field; host set without a port where required; environment-variable interpolation left the value blank; trailing quotes or whitespace pasted into config.","solutions":["Fix the target URL in the hubtest test configuration — include scheme and valid host:port (e.g. http://127.0.0.1:7422)","Quote URLs containing special characters in YAML to avoid parsing surprises"],"exampleFix":"// before (config)\nnuclei_target_host: \"127.0.0.1:8080 \"\n// after\nnuclei_target_host: \"http://127.0.0.1:8080\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(nucleiTargetHost)\nif err != nil || u.Host == \"\" {\n\treturn fmt.Errorf(\"invalid NucleiTargetHost %q\", nucleiTargetHost)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store full URLs with scheme and port in test configs","Lint test config values for stray whitespace/quotes"],"tags":["url","config","test-harness","appsec"],"backgroundTag":"invalid-url","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}