{"record":{"id":"ebafb4b8418d578c","repo":"SigNoz/signoz","slug":"failed-to-read-the-stored-config-correctly","errorCode":null,"errorMessage":"failed to read the stored config correctly","messagePattern":"failed to read the stored config correctly","errorType":"http","errorClass":"model.ApiError","httpStatus":400,"severity":"error","filePath":"pkg/query-service/agentConf/manager.go","lineNumber":246,"sourceCode":"}\n\nfunc Redeploy(ctx context.Context, orgId valuer.UUID, typ opamptypes.ElementType, version int) error {\n\tconfigVersion, err := GetConfigVersion(ctx, orgId, typ, version)\n\tif err != nil {\n\t\tslog.ErrorContext(ctx, \"failed to fetch config version during redeploy\", errors.Attr(err))\n\t\treturn err\n\t}\n\n\tif configVersion == nil || (configVersion != nil && configVersion.Config == \"\") {\n\t\tslog.DebugContext(ctx, \"config version has no conf yaml\", \"config_version\", configVersion)\n\t\treturn errors.NewInvalidInputf(CodeConfigVersionNoConfig, \"the config version can not be redeployed\")\n\t}\n\tswitch typ {\n\tcase opamptypes.ElementTypeSamplingRules:\n\t\tvar config *tsp.Config\n\t\tif err := yaml.Unmarshal([]byte(configVersion.Config), &config); err != nil {\n\t\t\tslog.DebugContext(ctx, \"failed to read last conf correctly\", errors.Attr(err))\n\t\t\treturn model.BadRequest(fmt.Errorf(\"failed to read the stored config correctly\"))\n\t\t}\n\n\t\t// merge current config with new filter params\n\t\tprocessorConf := map[string]interface{}{\n\t\t\t\"signoz_tail_sampling\": config,\n\t\t}\n\n\t\topamp.AddToTracePipelineSpec(\"signoz_tail_sampling\")\n\t\tconfigHash, err := opamp.UpsertControlProcessors(ctx, \"traces\", processorConf, m.OnConfigUpdate)\n\t\tif err != nil {\n\t\t\tslog.ErrorContext(ctx, \"failed to call agent config update for trace processor\", errors.Attr(err))\n\t\t\treturn errors.WithAdditionalf(err, \"failed to deploy the config\")\n\t\t}\n\n\t\tm.updateDeployStatus(ctx, orgId, opamptypes.ElementTypeSamplingRules, version, opamptypes.DeployInitiated.StringValue(), \"Deployment started\", configHash, configVersion.Config)\n\tcase opamptypes.ElementTypeDropRules:\n\t\tvar filterConfig *filterprocessor.Config\n\t\tif err := yaml.Unmarshal([]byte(configVersion.Config), &filterConfig); err != nil {","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/agentConf/manager.go#L228-L264","documentation":"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.","triggerScenarios":"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.","commonSituations":"Downgrades or version skips that change the tail-sampling config schema, manually edited agent_conf rows, or partially written configs.","solutions":["Inspect the stored config YAML for the affected version in the DB","Fix or re-save the sampling config in the current schema (UI or API)","If version drift, redeploy a fresh config rather than the stale one"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"On unmarshal failure, fall back to creating a fresh sampling config rather than redeploying the corrupt stored one; log the stored YAML for forensics.","preventionTips":["Don't hand-edit stored agent configs","Re-save configs through the API after version upgrades"],"tags":["yaml","agent-conf","sampling","redeploy"],"backgroundTag":"yaml-parse-error","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}