goharbor/harbor · error
parse Ldap Host ERR
Error message
parse Ldap Host ERR: %s
What it means
Guard in ldap formatURL: url.Parse failed on the configured LDAP URL, so the host/protocol cannot be extracted and the LDAP session cannot be opened.
Solutions
- Fix the LDAP URL syntax, e.g. 'ldap://host:389' or 'ldaps://host:636'
- Check for control characters, spaces or missing host in the ldap_url setting
- Re-test after correcting the LDAP configuration
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/pkg/ldap/ldap.go:81 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/04761a1fc2ae338a.
Report an issue: GitHub.
Appendix: source
Thrown at src/pkg/ldap/ldap.go:81
type Session struct {
basicCfg models.LdapConf
groupCfg models.GroupConf
ldapConn *goldap.Conn
}
// NewSession create session with configs
func NewSession(basicCfg models.LdapConf, groupCfg models.GroupConf) *Session {
return &Session{
basicCfg: basicCfg,
groupCfg: groupCfg,
}
}
func formatURL(ldapURL string) (string, error) {
var protocol, hostport string
_, err := url.Parse(ldapURL)
if err != nil {
return "", fmt.Errorf("parse Ldap Host ERR: %s", err)
}
if strings.Contains(ldapURL, "://") {
splitLdapURL := strings.Split(ldapURL, "://")
protocol, hostport = splitLdapURL[0], splitLdapURL[1]
if !((protocol == "ldap") || (protocol == "ldaps")) {
return "", fmt.Errorf("unknown ldap protocol")
}
} else {
hostport = ldapURL
protocol = "ldap"
}
if strings.Contains(hostport, ":") {
_, port, err := net.SplitHostPort(hostport)
if err != nil {
return "", fmt.Errorf("illegal ldap url, error: %v", err)
}View on GitHub (pinned to 7b2fd08cc5)