goharbor/harbor · error

expect filter value to be string, but got

Error message

expect filter value to be string, but got: %v

What it means

getStringFilterValue (used by DockerHub FetchArtifacts) found a filter of the expected type but its Value field failed the string type assertion — the replication rule stored the filter value as some other dynamic type (e.g. number or bool).

Solutions

  1. Re-create the replication rule storing the filter value as a JSON string
  2. Add a client-side type check on filter.Value before calling the adapter
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/pkg/reg/adapter/dockerhub/adapter.go:473 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/76ebe6e15a904df3. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/reg/adapter/dockerhub/adapter.go:473

	tags := &TagsResp{}
	err = json.Unmarshal(body, tags)
	if err != nil {
		return nil, fmt.Errorf("unmarshal tags list %s error: %v", string(body), err)
	}

	return tags, nil
}

// getStringFilterValue gets specific type filter value from filters list.
func (a *adapter) getStringFilterValue(filterType string, filters []*model.Filter) (string, error) {
	for _, f := range filters {
		if f.Type == filterType {
			v, ok := f.Value.(string)
			if !ok {
				msg := fmt.Sprintf("expect filter value to be string, but got: %v", f.Value)
				log.Error(msg)
				return "", errors.New(msg)
			}
			return v, nil
		}
	}
	return "", nil
}

View on GitHub (pinned to 7b2fd08cc5)