{"record":{"id":"9a9eb2726399cae8","repo":"hyperledger/fabric","slug":"empty-channel-id","errorCode":null,"errorMessage":"empty channel id","messagePattern":"empty channel id","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/channelparticipation/validator.go","lineNumber":93,"sourceCode":"\tif err != nil {\n\t\treturn \"\", errors.New(\"bad payload\")\n\t}\n\n\tif payload.Header == nil || payload.Header.ChannelHeader == nil {\n\t\treturn \"\", errors.New(\"bad header\")\n\t}\n\n\tch, err := protoutil.UnmarshalChannelHeader(payload.Header.ChannelHeader)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"could not unmarshall channel header\")\n\t}\n\n\tif ch.Type != int32(cb.HeaderType_CONFIG_UPDATE) {\n\t\treturn \"\", errors.New(\"bad type\")\n\t}\n\n\tif ch.ChannelId == \"\" {\n\t\treturn \"\", errors.New(\"empty channel id\")\n\t}\n\n\tconfigUpdateEnv, err := protoutil.EnvelopeToConfigUpdate(env)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tconfigUpdate, err := configtx.UnmarshalConfigUpdate(configUpdateEnv.ConfigUpdate)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn configUpdate.ChannelId, nil\n}\n\n// ValidateFetchBlockID checks the block id. He can be: newest|oldest|config|(number)\nfunc ValidateFetchBlockID(blockID string) error {\n\t// Length","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/channelparticipation/validator.go#L75-L111","documentation":"ValidateUpdateConfigEnvelope guard: the channel header decoded and had the correct CONFIG_UPDATE type, but its ChannelId field is an empty string. A config update envelope must name the target channel; this also serves to reject legacy system-channel style updates.","triggerScenarios":"Constructing a CONFIG_UPDATE envelope with a ChannelHeader that leaves ChannelId unset, or a client that derives the channel ID from a variable that is empty in the environment/config.","commonSituations":"CHANNLE_ID / CHANNEL_NAME env var not exported in a CI script; templated deployment where the channel name placeholder was not substituted; hand-built ChannelHeader missing ChannelId.","solutions":["Set ChannelHeader.ChannelId to the exact channel name before signing: ch.ChannelId = \"mychannel\".","Fix the environment variable or template substitution so the channel name is non-empty in the submission script.","Validate client-side before submitting: fail fast if channelId == \"\".","Regenerate the envelope with protoutil.CreateSignedEnvelope(channelID, ...) which stamps the channel ID into the header."],"exampleFix":"// before\nch := &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG_UPDATE)} // ChannelId empty\n// after\nch := &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG_UPDATE), ChannelId: \"mychannel\"}","handlingStrategy":"validation","validationCode":"if ch.ChannelId == \"\" {\n    return errors.New(\"channel id must be set in the ChannelHeader before signing\")\n}","typeGuard":"func hasChannelID(env *cb.Envelope) bool {\n    p, err := protoutil.UnmarshalPayload(env.Payload)\n    if err != nil || p.Header == nil || p.Header.ChannelHeader == nil { return false }\n    ch, _ := protoutil.UnmarshalChannelHeader(p.Header.ChannelHeader)\n    return ch != nil && ch.ChannelId != \"\"\n}","tryCatchPattern":"if _, err := ValidateUpdateConfigEnvelope(env); err != nil && strings.Contains(err.Error(), \"empty channel id\") {\n    // set ChannelHeader.ChannelId and re-sign the envelope\n}","preventionTips":["Fail fast when channel name env vars/templates are empty","Use protoutil.CreateSignedEnvelope which stamps the channel ID","Sanity-check that ChannelId matches the channel used in the API URL","Add pre-submission validation of all required ChannelHeader fields"],"tags":["fabric","orderer","missing-channel-id","validation"],"backgroundTag":"missing-required-argument","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"}