vitessio/vitess · error

err.Error() (GetDetectionAnalysis failure)

Error message

err.Error() (GetDetectionAnalysis failure)

What it means

The /detection-analysis handler returns HTTP 500 with the raw error text when inst.GetDetectionAnalysis(keyspace, shard, hints) fails. This means the analysis computation itself (reading detection data from vtorc's internals) errored, distinct from the 400 parameter-validation error above it.

Source

Thrown at go/vt/vtorc/server/api.go:326

	}
	if b, err := json.Marshal(topoproto.TabletAliasString(lij.InstanceAlias)); err == nil {
		m["InstanceAlias"] = b
	}
	return json.Marshal(m)
}

// detectionAnalysisAPIHandler is the handler for the detectionAnalysisAPI endpoint
func detectionAnalysisAPIHandler(response http.ResponseWriter, request *http.Request) {
	// This api also supports filtering by shard and keyspace provided.
	shard := request.URL.Query().Get("shard")
	keyspace := request.URL.Query().Get("keyspace")
	if shard != "" && keyspace == "" {
		http.Error(response, shardWithoutKeyspaceFilteringErrorStr, http.StatusBadRequest)
		return
	}
	analysis, err := inst.GetDetectionAnalysis(keyspace, shard, &inst.DetectionAnalysisHints{})
	if err != nil {
		http.Error(response, err.Error(), http.StatusInternalServerError)
		return
	}
	var processed []*LegacyDetectionAnalysisJSON
	for _, a := range analysis {
		processed = append(processed, NewLegacyDetectionAnalysisJSON(a))
	}
	returnAsJSON(response, http.StatusOK, processed)
}

// healthAPIHandler is the handler for the healthAPI endpoint
func healthAPIHandler(response http.ResponseWriter, request *http.Request) {
	health, discoveredOnce := process.HealthTest()
	code := http.StatusOK
	// If the process isn't healthy, or if the first discovery cycle hasn't completed, we return an internal server error.
	if !health.Healthy || !discoveredOnce {
		code = http.StatusInternalServerError
	}
	returnAsJSON(response, code, health)

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check vtorc logs for the underlying GetDetectionAnalysis error
  2. Verify the keyspace/shard values exist in the keyspace vtorc monitors
  3. Wait for vtorc to complete startup/rediscovery, then retry the request
Defensive patterns

Strategy: retry

Validate before calling

if keyspace != "" {
    // confirm the keyspace is known to vtorc before querying
}

Try / catch

resp, err := http.Get(vtorcURL + "/detection-analysis?keyspace=" + url.QueryEscape(keyspace))
if resp != nil && resp.StatusCode == http.StatusInternalServerError {
    // log body, retry after backoff
}

Prevention

When it happens

Trigger: GET /detection-analysis with valid (or empty) keyspace/shard filters while GetDetectionAnalysis returns an error — e.g. internal state unavailable or invalid keyspace/shard lookup failing.

Common situations: Querying a keyspace that vtorc is not monitoring; vtorc internal store not yet populated after startup; passing malformed shard specs that the analysis code cannot resolve.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/98baed996186452e. Report an issue: GitHub.