{"record":{"id":"04761a1fc2ae338a","repo":"goharbor/harbor","slug":"parse-ldap-host-err-s","errorCode":null,"errorMessage":"parse Ldap Host ERR: %s","messagePattern":"parse Ldap Host ERR: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/ldap/ldap.go","lineNumber":81,"sourceCode":"type Session struct {\n\tbasicCfg models.LdapConf\n\tgroupCfg models.GroupConf\n\tldapConn *goldap.Conn\n}\n\n// NewSession create session with configs\nfunc NewSession(basicCfg models.LdapConf, groupCfg models.GroupConf) *Session {\n\treturn &Session{\n\t\tbasicCfg: basicCfg,\n\t\tgroupCfg: groupCfg,\n\t}\n}\n\nfunc formatURL(ldapURL string) (string, error) {\n\tvar protocol, hostport string\n\t_, err := url.Parse(ldapURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"parse Ldap Host ERR: %s\", err)\n\t}\n\n\tif strings.Contains(ldapURL, \"://\") {\n\t\tsplitLdapURL := strings.Split(ldapURL, \"://\")\n\t\tprotocol, hostport = splitLdapURL[0], splitLdapURL[1]\n\t\tif !((protocol == \"ldap\") || (protocol == \"ldaps\")) {\n\t\t\treturn \"\", fmt.Errorf(\"unknown ldap protocol\")\n\t\t}\n\t} else {\n\t\thostport = ldapURL\n\t\tprotocol = \"ldap\"\n\t}\n\n\tif strings.Contains(hostport, \":\") {\n\t\t_, port, err := net.SplitHostPort(hostport)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"illegal ldap url, error: %v\", err)\n\t\t}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/ldap/ldap.go#L63-L99","documentation":"Error \"parse Ldap Host ERR: %s\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/pkg/ldap/ldap.go:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}