{"record":{"id":"f2ba9160620c0a65","repo":"temporalio/temporal","slug":"queue-with-type-v-and-name-v-has-invalid-encodin","errorCode":null,"errorMessage":"queue with type %v and name %v has invalid encoding: %w","messagePattern":"queue with type (.+?) and name (.+?) has invalid encoding: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/persistence/sql/queue_v2.go","lineNumber":352,"sourceCode":"\tcase sqlplugin.Tx:\n\t\tmetadata, err = tc.SelectFromQueueV2MetadataForUpdate(ctx, filter)\n\tdefault:\n\t\tmetadata, err = tc.SelectFromQueueV2Metadata(ctx, filter)\n\t}\n\tif err != nil {\n\t\tif errors.Is(err, sql.ErrNoRows) {\n\t\t\treturn nil, persistence.NewQueueNotFoundError(queueType, queueName)\n\t\t}\n\t\treturn nil, serviceerror.NewUnavailablef(\n\t\t\t\"failed to get metadata for queue with type: %v and name: %v. Error: %v\", queueType, queueName, err,\n\t\t)\n\t}\n\treturn q.extractQueueMetadata(metadata)\n}\n\nfunc (q queueV2) extractQueueMetadata(metadataRow *sqlplugin.QueueV2MetadataRow) (*persistencespb.Queue, error) {\n\tif metadataRow.MetadataEncoding != enumspb.ENCODING_TYPE_PROTO3.String() {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"queue with type %v and name %v has invalid encoding: %w\",\n\t\t\tmetadataRow.QueueType,\n\t\t\tmetadataRow.QueueName,\n\t\t\tserialization.NewUnknownEncodingTypeError(metadataRow.MetadataEncoding, enumspb.ENCODING_TYPE_PROTO3),\n\t\t)\n\t}\n\tqm := &persistencespb.Queue{}\n\terr := qm.Unmarshal(metadataRow.MetadataPayload)\n\tif err != nil {\n\t\treturn nil, serialization.NewDeserializationError(\n\t\t\tenumspb.ENCODING_TYPE_PROTO3,\n\t\t\tfmt.Errorf(\"unmarshal payload for queue with type %v and name %v failed: %w\",\n\t\t\t\tmetadataRow.QueueType,\n\t\t\t\tmetadataRow.QueueName,\n\t\t\t\terr),\n\t\t)\n\t}\n\treturn qm, nil","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/persistence/sql/queue_v2.go#L334-L370","documentation":"extractQueueMetadata verifies that a queue V2 metadata row was encoded with proto3; any other MetadataEncoding string triggers serialization.NewUnknownEncodingTypeError wrapped with the queue type/name. It guards against reading metadata written by an incompatible encoder or corrupted rows.","triggerScenarios":"getQueueMetadata or getMessageCountAndLastID reads a queue_metadata_v2 row whose MetadataEncoding column is not \"proto3\", then calls extractQueueMetadata.","commonSituations":"Rows written by a custom tool or older/experimental version using a different encoding; manual DB edits; corruption of the MetadataEncoding column; mixed-version cluster during upgrade.","solutions":["Identify the queue from the message (type and name are printed) and inspect its metadata row's MetadataEncoding value in the database.","Rewrite the metadata row with valid proto3-encoded payload (MetadataEncoding = \"proto3\") if it was hand-modified.","Ensure all cluster nodes run a compatible Temporal version so no legacy encodings are written.","Delete and recreate the queue if its metadata is unrecoverable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// inspect the offending row before use\nvar enc string\ndb.QueryRow(\"SELECT metadata_encoding FROM queue_metadata_v2 WHERE queue_type=? AND queue_name=?\", qt, qn).Scan(&enc)\nif enc != \"proto3\" {\n    // row is unreadable by this code path; repair or recreate\n}","typeGuard":null,"tryCatchPattern":"qm, err := store.GetQueueMetadata(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"invalid encoding\") {\n    // rebuild/recreate the queue; metadata is incompatible\n}","preventionTips":["Never hand-edit persistence tables; use Temporal tooling only.","Keep all cluster nodes on a compatible version to avoid mixed encodings.","Back up the database before schema or version upgrades."],"tags":["serialization","queue","encoding","data-corruption"],"backgroundTag":"unknown-encoding-type","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}