t8y2/dbx · error
Unexpected management API response for list endpoint %s
Error message
Unexpected management API response for list endpoint %s
What it means
managementGetAll pages through a RabbitMQ management API list endpoint and accepts either a plain JSON array or a paginated object with an "items" key; a map without "items" is an unexpected shape and returns this error naming the endpoint path. It guards against API changes or hitting a non-list resource.
Source
Thrown at agents/drivers/rabbitmq/management.go:160
func managementGetAll(connection jsonObject, path string) ([]any, error) {
all := make([]any, 0)
for page := 1; ; page++ {
separator := "?"
if strings.Contains(path, "?") {
separator = "&"
}
response, err := managementGet(connection,
path+separator+"page="+strconv.Itoa(page)+"&page_size="+strconv.Itoa(managementPageSize))
if err != nil {
return nil, err
}
switch typed := response.(type) {
case []any:
return append(all, typed...), nil
case map[string]any:
items, exists := typed["items"]
if !exists {
return nil, fmt.Errorf("Unexpected management API response for list endpoint %s", path)
}
if array, ok := items.([]any); ok {
all = append(all, array...)
}
pageCount := integerOrNull(jsonObject(typed), "page_count")
if pageCount == nil || page >= *pageCount {
return all, nil
}
default:
return nil, fmt.Errorf("Unexpected management API response for list endpoint %s", path)
}
}
}
func managementBaseURLs(connection jsonObject) ([]string, error) {
if explicit := stringOrNull(connection, "management_url"); explicit != nil && strings.TrimSpace(*explicit) != "" {
return []string{normalizeManagementURL(*explicit)}, nil
}View on GitHub (pinned to c0390bff16)
Solutions
- Log/inspect the raw management response body for the endpoint to see the actual object
- Fix the endpoint path/vhost (a 404 error object lacks "items")
- Verify management API credentials and permissions
- Check RabbitMQ version compatibility with the expected paginated response format
Example fix
// diagnose: the object was {"error":"not_found","reason":"..."}
// before
"http://localhost:15672/api/topics/%2F"
// after
"http://localhost:15672/api/exchanges/%2F" Defensive patterns
Strategy: type-guard
Validate before calling
// preflight the endpoint with a raw request before paging
resp, err := http.Get(baseURL + path)
if err != nil { return err }
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("management endpoint %s unhealthy: %d %s", path, resp.StatusCode, body)
} Type guard
func isPaginatedList(m map[string]any) bool {
_, ok := m["items"].([]any)
return ok
}
func isPlainArray(v any) bool { _, ok := v.([]any); return ok } Try / catch
all, err := managementGetAll(client, path)
if err != nil && strings.Contains(err.Error(), "Unexpected management API response") {
log.Fatalf("endpoint %s returned unexpected shape; check RabbitMQ version and auth: %v", path, err)
} Prevention
- Check HTTP status before decoding JSON bodies in management calls
- Log raw response bodies when the shape does not match expectations
- Test against the RabbitMQ management API version you deploy
- Handle error objects ({"error":...}) distinctly from list payloads
When it happens
Trigger: The management HTTP response for the given path is a JSON object lacking "items" — e.g. an error object like {"error":"not_found","reason":"..."}, an authentication/API version payload, or the wrong URL returning a single-entity map.
Common situations: RabbitMQ management API version mismatch changing response shape; wrong vhost/path causing a not_found error object; unauthenticated response object; reverse proxy returning an HTML/JSON error map.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- Unexpected management API response for vhost listing
- Unexpected management API response for cluster overview
- Unexpected management API response for node listing
- No management API endpoint candidates
- Unexpected management API response for queue details
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/2400aba1f90cd95f.
Report an issue: GitHub.