SigNoz/signoz · error · model.ApiError

failed to read the stored config correctly

Error message

failed to read the stored config correctly

What it means

During Redeploy of sampling rules, the stored YAML config version cannot be unmarshalled into the tail-sampling Config struct. The stored agent config is corrupt or was written in an incompatible schema; the DB error path logs at debug and returns BadRequest.

Source

Thrown at pkg/query-service/agentConf/manager.go:246

}

func Redeploy(ctx context.Context, orgId valuer.UUID, typ opamptypes.ElementType, version int) error {
	configVersion, err := GetConfigVersion(ctx, orgId, typ, version)
	if err != nil {
		slog.ErrorContext(ctx, "failed to fetch config version during redeploy", errors.Attr(err))
		return err
	}

	if configVersion == nil || (configVersion != nil && configVersion.Config == "") {
		slog.DebugContext(ctx, "config version has no conf yaml", "config_version", configVersion)
		return errors.NewInvalidInputf(CodeConfigVersionNoConfig, "the config version can not be redeployed")
	}
	switch typ {
	case opamptypes.ElementTypeSamplingRules:
		var config *tsp.Config
		if err := yaml.Unmarshal([]byte(configVersion.Config), &config); err != nil {
			slog.DebugContext(ctx, "failed to read last conf correctly", errors.Attr(err))
			return model.BadRequest(fmt.Errorf("failed to read the stored config correctly"))
		}

		// merge current config with new filter params
		processorConf := map[string]interface{}{
			"signoz_tail_sampling": config,
		}

		opamp.AddToTracePipelineSpec("signoz_tail_sampling")
		configHash, err := opamp.UpsertControlProcessors(ctx, "traces", processorConf, m.OnConfigUpdate)
		if err != nil {
			slog.ErrorContext(ctx, "failed to call agent config update for trace processor", errors.Attr(err))
			return errors.WithAdditionalf(err, "failed to deploy the config")
		}

		m.updateDeployStatus(ctx, orgId, opamptypes.ElementTypeSamplingRules, version, opamptypes.DeployInitiated.StringValue(), "Deployment started", configHash, configVersion.Config)
	case opamptypes.ElementTypeDropRules:
		var filterConfig *filterprocessor.Config
		if err := yaml.Unmarshal([]byte(configVersion.Config), &filterConfig); err != nil {

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Inspect the stored config YAML for the affected version in the DB
  2. Fix or re-save the sampling config in the current schema (UI or API)
  3. If version drift, redeploy a fresh config rather than the stale one
Defensive patterns

Strategy: fallback

Try / catch

On unmarshal failure, fall back to creating a fresh sampling config rather than redeploying the corrupt stored one; log the stored YAML for forensics.

Prevention

When it happens

Trigger: Calling Redeploy with ElementTypeSamplingRules when the stored configVersion.Config YAML does not match tsp.Config — leftover config from an older version, manual DB edits, or truncated writes.

Common situations: Downgrades or version skips that change the tail-sampling config schema, manually edited agent_conf rows, or partially written configs.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/ebafb4b8418d578c. Report an issue: GitHub.