goharbor/harbor · error

and list must start with "(" and end with ")"

Error message

and list must start with "(" and end with ")"

What it means

Syntax error in q.parseList for AND lists: the value does not end with ')' to match its leading '(', so it is not a valid '(a b c)' and-list token.

Solutions

  1. Close the list with ')', e.g. '(a b c)'
  2. Check for unbalanced parentheses in the query value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/q/builder.go:176 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/0cc615f25f9629b7. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/q/builder.go:176

}

func parseAndList(value string) (*AndList, error) {
	values, err := parseList(value, '(')
	if err != nil {
		return nil, err
	}
	al := &AndList{}
	al.Values = append(al.Values, values...)
	return al, nil
}

func parseList(value string, c rune) ([]any, error) {
	length := len(value)
	if c == '{' && value[length-1] != '}' {
		return nil, fmt.Errorf(`or list must start with "{" and end with "}"`)
	}
	if c == '(' && value[length-1] != ')' {
		return nil, fmt.Errorf(`and list must start with "(" and end with ")"`)
	}
	var vs []any

	for str := range strings.SplitSeq(value[1:length-1], " ") {
		v := parseValue(str)
		if s, ok := v.(string); ok && len(s) == 0 {
			continue
		}
		vs = append(vs, v)
	}
	return vs, nil
}

// try to parse value as time first, then integer, and last string
func parseValue(value string) any {
	value = strings.TrimSpace(value)
	// try to parse time
	time, err := time.Parse("2006-01-02T15:04:05", value)

View on GitHub (pinned to 7b2fd08cc5)