{"record":{"id":"380aa54a0fc35629","repo":"thanos-io/thanos","slug":"unknown-replication-protocol-v","errorCode":null,"errorMessage":"unknown replication protocol %v","messagePattern":"unknown replication protocol (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/handler.go","lineNumber":1986,"sourceCode":"\tif isLocalEndpoint(endpoint, p.localEndpoint) {\n\t\tclient = &localAsyncWriter{\n\t\t\tw: p.writer,\n\t\t}\n\t} else {\n\t\tswitch p.replicationProtocol {\n\t\tcase CapNProtoReplication:\n\t\t\tclient = writecapnp.NewRemoteWriteClient(writecapnp.NewTCPDialer(endpoint.CapNProtoAddress), p.logger)\n\n\t\tcase ProtobufReplication:\n\t\t\tconn, err := p.dialer(endpoint.Address, p.dialOpts...)\n\t\t\tif err != nil {\n\t\t\t\tp.markPeerUnavailableUnlocked(endpoint)\n\t\t\t\tdialError := errors.Wrap(err, \"failed to dial peer\")\n\t\t\t\treturn nil, errors.Wrap(dialError, errUnavailable.Error())\n\t\t\t}\n\t\t\tclient = newProtobufPeer(conn)\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"unknown replication protocol %v\", p.replicationProtocol)\n\t\t}\n\t}\n\n\tvar delay time.Duration\n\tif p.conns.Load() == 2 {\n\t\tdelay = p.maxArtificialDelay\n\t}\n\n\tp.connections[endpoint] = newPeerWorker(client, p.forwardDelay.WithLabelValues(endpoint.Address), p.asyncForwardWorkersCount, delay)\n\treturn p.connections[endpoint], nil\n}\n\nfunc (p *peerGroup) markPeerUnavailable(addr Endpoint) {\n\tp.m.Lock()\n\tdefer p.m.Unlock()\n\n\tp.markPeerUnavailableUnlocked(addr)\n}","sourceCodeStart":1968,"sourceCodeEnd":2004,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler.go#L1968-L2004","documentation":"This error is a programmer/configuration invariant error raised in peerGroup.getConnection when p.replicationProtocol is neither CapNProtoReplication nor ProtobufReplication. The replication protocol field is set from flags/config at peerGroup construction, so hitting this default branch means an unsupported or unset protocol value reached the switch. It is not transient — every dial attempt for a non-local endpoint will fail with the same message.","triggerScenarios":"Returned whenever getConnection reaches the switch on p.replicationProtocol with an unrecognized value, i.e. a nil/zero or out-of-enum ReplicationProtocol value was used when building the peerGroup.","commonSituations":"Newer/older Thanos binaries or clients speaking a protocol the peer doesn't support; a code path constructing peerGroup without setting replicationProtocol; custom integrations setting the protocol via an unvalidated config value.","solutions":["Check which replication protocol flag/version produced this value and upgrade/downgrade the affected Thanos component so both sides agree.","Inspect the code constructing peerGroup and ensure replicationProtocol is explicitly set to CapNProtoReplication or ProtobufReplication.","If setting the protocol from config, validate it against the supported enum before constructing the peerGroup.","Report a bug if a stock Thanos binary hits this, since valid flags should always map to a supported protocol."],"exampleFix":"// before: protocol parsed unvalidated\np.replicationProtocol = ReplicationProtocol(cfg[\"protocol\"])\n// after: validate against supported values\nproto, err := parseReplicationProtocol(cfg[\"protocol\"])\nif err != nil {\n\treturn nil, errors.Wrap(err, \"unsupported replication protocol in config\")\n}\np.replicationProtocol = proto","handlingStrategy":"validation","validationCode":"// Go: validate protocol enum before building peerGroup\nswitch proto {\ncase CapNProtoReplication, ProtobufReplication:\n\t// ok\ndefault:\n\treturn nil, errors.Errorf(\"unsupported replication protocol %v\", proto)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set ReplicationProtocol from a fixed set of constants, never raw config strings.","Add an enum parse function with error on unknown values at startup.","Fail fast at process start with a validation check rather than at first write.","Version-check components after upgrades that introduce new replication protocols."],"tags":["configuration","invalid-enum","thanos-receive","replication-protocol"],"backgroundTag":"invalid-enum-value","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}