{"record":{"id":"9a251ed33bb55480","repo":"hyperledger/fabric","slug":"tag-should-be-s","errorCode":null,"errorMessage":"Tag should be %s","messagePattern":"Tag should be (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gossip/protoext/message.go","lineNumber":135,"sourceCode":"// IsDigestMsg returns whether this GossipMessage is a digest message\nfunc IsDigestMsg(m *gossip.GossipMessage) bool {\n\treturn m.GetDataDig() != nil\n}\n\n// IsLeadershipMsg returns whether this GossipMessage is a leadership (leader election) message\nfunc IsLeadershipMsg(m *gossip.GossipMessage) bool {\n\treturn m.GetLeadershipMsg() != nil\n}\n\n// IsTagLegal checks the GossipMessage tags and inner type\n// and returns an error if the tag doesn't match the type.\nfunc IsTagLegal(m *gossip.GossipMessage) error {\n\tif m.Tag == gossip.GossipMessage_UNDEFINED {\n\t\treturn fmt.Errorf(\"Undefined tag\")\n\t}\n\tif IsDataMsg(m) {\n\t\tif m.Tag != gossip.GossipMessage_CHAN_AND_ORG {\n\t\t\treturn fmt.Errorf(\"Tag should be %s\", gossip.GossipMessage_Tag_name[int32(gossip.GossipMessage_CHAN_AND_ORG)])\n\t\t}\n\t\treturn nil\n\t}\n\n\tif IsAliveMsg(m) || m.GetMemReq() != nil || m.GetMemRes() != nil {\n\t\tif m.Tag != gossip.GossipMessage_EMPTY {\n\t\t\treturn fmt.Errorf(\"Tag should be %s\", gossip.GossipMessage_Tag_name[int32(gossip.GossipMessage_EMPTY)])\n\t\t}\n\t\treturn nil\n\t}\n\n\tif IsIdentityMsg(m) {\n\t\tif m.Tag != gossip.GossipMessage_ORG_ONLY {\n\t\t\treturn fmt.Errorf(\"Tag should be %s\", gossip.GossipMessage_Tag_name[int32(gossip.GossipMessage_ORG_ONLY)])\n\t\t}\n\t\treturn nil\n\t}\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/gossip/protoext/message.go#L117-L153","documentation":"IsTagLegal requires a data message (IsDataMsg) to carry the CHAN_AND_ORG tag so the message is disseminated only to channel members of the same org. A data message tagged with anything else is rejected with this formatted error naming the expected tag.","triggerScenarios":"Sending/gossiping a GossipMessage that IsDataMsg classifies as a data message (HasDataMsg payload) but whose Tag != GossipMessage_CHAN_AND_ORG; caught by validateMsg on send in the Gossip service or by tests.","commonSituations":"Hand-crafted DataMsg built with Tag EMPTY, UNDEFINED, or ORG_ONLY; a refactor changed the payload but not the tag; interop with a peer producing malformed data messages.","solutions":["Set msg.Tag = gossip.GossipMessage_CHAN_AND_ORG on all data messages before sending.","Run IsTagLegal on outgoing messages in tests to catch mismatches early.","If receiving this on the wire, the remote peer is misconfigured/malicious; rely on validateMsg to drop the message.","Check that the payload type actually is a data message; if not, fix the message construction."],"exampleFix":"// before\nm := &gossip.GossipMessage{Content: &gossip.GossipMessage_DataMsg{DataMsg: d}}\n// after\nm := &gossip.GossipMessage{\n    Tag: gossip.GossipMessage_CHAN_AND_ORG,\n    Content: &gossip.GossipMessage_DataMsg{DataMsg: d},\n}","handlingStrategy":"validation","validationCode":"func makeDataMsg(d *gossip.DataMessage) *gossip.GossipMessage {\n    return &gossip.GossipMessage{\n        Tag: gossip.GossipMessage_CHAN_AND_ORG,\n        Content: &gossip.GossipMessage_DataMsg{DataMsg: d},\n    }\n}","typeGuard":"func isLegallyTaggedDataMsg(m *gossip.GossipMessage) bool {\n    return protoext.IsDataMsg(m) && m.Tag == gossip.GossipMessage_CHAN_AND_ORG\n}","tryCatchPattern":"if err := protoext.IsTagLegal(msg); err != nil {\n    log.Warningf(\"illegal data message tag: %v\", err)\n    return\n}","preventionTips":["Use a single factory for data messages that pins Tag = CHAN_AND_ORG.","Test tag legality whenever message payloads change.","Drop inbound data messages failing validateMsg at the receiving peer.","Never copy Tag values between messages of different types."],"tags":["hyperledger-fabric","gossip","message-validation"],"backgroundTag":"gossip-message-tag-mismatch","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}