VictoriaMetrics/VictoriaMetrics · error

cannot parse response from %q: %w; data=%q

Error message

cannot parse response from %q: %w; data=%q

What it means

Raised in nomadWatcher.getBlockingServiceNames when the JSON body of the Nomad /v1/services blocking query fails to unmarshal into []ServiceList; %q includes the raw data to reveal error pages or schema changes.

Source

Thrown at lib/promscrape/discovery/nomad/watch.go:218

)

// getBlockingServiceNames obtains service names via blocking request to Nomad.
//
// It returns an empty serviceNames list if response contains the same index.
func (cw *nomadWatcher) getBlockingServiceNames(index int64) ([]string, int64, error) {
	path := "/v1/services" + cw.serviceNamesQueryArgs
	data, newIndex, err := getBlockingAPIResponse(cw.client.Context(), cw.client, path, index)
	if err != nil {
		return nil, index, err
	}
	if index == newIndex {
		// Nothing changed - return an empty serviceNames list.
		return nil, index, nil
	}

	var svcs []ServiceList
	if err := json.Unmarshal(data, &svcs); err != nil {
		return nil, index, fmt.Errorf("cannot parse response from %q: %w; data=%q", path, err, data)
	}

	serviceNames := make([]string, 0, len(svcs))
	for _, svc := range svcs {
		for _, s := range svc.Services {
			serviceNames = append(serviceNames, s.ServiceName)
		}
	}

	return serviceNames, newIndex, nil
}

// getServiceSnapshot returns a snapshot of discovered Services.
func (cw *nomadWatcher) getServiceSnapshot() map[string][]Service {
	cw.servicesLock.Lock()
	sns := make(map[string][]Service, len(cw.services))
	for svc, sw := range cw.services {
		sns[svc] = sw.services

View on GitHub (pinned to 5079fb58f1)

Solutions

  1. Inspect the echoed data — a Nomad error payload indicates ACL/auth problems
  2. Verify the Nomad API version matches the expected services schema
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at lib/promscrape/discovery/nomad/watch.go:218 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03). Data as JSON: /api/errors/15e0878d84490ab0. Report an issue: GitHub.