goharbor/harbor · error

received unexpected status code

Error message

received unexpected status code: %d %s

What it means

Error from HTTPStatusCodeHealthChecker: the probe reached the endpoint but the response status code differs from the expected one configured at checker construction. The message includes the actual code and as much of the response body as could be read to aid diagnosis.

Solutions

  1. Check the target service - a 5xx indicates it is unhealthy.
  2. Verify the expected statusCode configured for the checker matches the endpoint's contract.
  3. Inspect the response body in the message for the service's own error detail.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/controller/health/checker.go:66 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/0e1d1e6ad7e0d83a. Report an issue: GitHub.

Appendix: source

Thrown at src/controller/health/checker.go:66

				req.Header.Add(key, value)
			}
		}

		client := httputil.NewClient(&http.Client{
			Transport: httputil.GetHTTPTransport(),
			Timeout:   timeout,
		})
		resp, err := client.Do(req)
		if err != nil {
			return fmt.Errorf("failed to check health: %v", err)
		}
		defer resp.Body.Close()
		if resp.StatusCode != statusCode {
			data, err := io.ReadAll(resp.Body)
			if err != nil {
				log.Debugf("failed to read response body: %v", err)
			}
			return fmt.Errorf("received unexpected status code: %d %s", resp.StatusCode, string(data))
		}

		return nil
	})
}

type updater struct {
	sync.Mutex
	status error
}

func (u *updater) Check() error {
	u.Lock()
	defer u.Unlock()

	return u.status
}

View on GitHub (pinned to 7b2fd08cc5)