hyperledger/fabric · error

failed fetching config for channel %s

Error message

failed fetching config for channel %s

What it means

This error is returned by configQuery when s.Config(q.Channel) fails to fetch the channel configuration. The discovery service must load a valid, up-to-date channel config to answer config queries; any failure reading or computing that config produces this wrapped error, with the root cause logged server-side.

Source

Thrown at discovery/service.go:158

			return wrapError(errors.Errorf("failed constructing descriptor for %v", interest))
		}
		descriptors = append(descriptors, desc)
	}

	return &discovery.QueryResult{
		Result: &discovery.QueryResult_CcQueryRes{
			CcQueryRes: &discovery.ChaincodeQueryResult{
				Content: descriptors,
			},
		},
	}
}

func (s *Service) configQuery(q *discovery.Query) *discovery.QueryResult {
	conf, err := s.Config(q.Channel)
	if err != nil {
		logger.Errorf("Failed fetching config for channel %s: %v", q.Channel, err)
		return wrapError(errors.Errorf("failed fetching config for channel %s", q.Channel))
	}
	return &discovery.QueryResult{
		Result: &discovery.QueryResult_ConfigResult{
			ConfigResult: conf,
		},
	}
}

func wrapPeerResponse(peersByOrg map[string]*discovery.Peers) *discovery.QueryResult {
	return &discovery.QueryResult{
		Result: &discovery.QueryResult_Members{
			Members: &discovery.PeerMembershipResult{
				PeersByOrg: peersByOrg,
			},
		},
	}
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Verify the channel name in the discovery request matches an existing channel ('peer channel list' on a peer)
  2. Check the server log 'Failed fetching config for channel %s' for the root error from s.Config
  3. Confirm the peer handling discovery has joined the channel and its ledger contains the config block
  4. If the channel was recently created, retry after peers have finished processing the genesis/config block

Example fix

// before
req := discovery.NewConfigQuery().AddQuery("mychanel") // misspelled channel
// after
req := discovery.NewConfigQuery().AddQuery("mychannel") // verified via 'peer channel list'
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec("peer channel list")
if err != nil || !strings.Contains(string(out), channel) {
    return fmt.Errorf("channel %s not joined by peer; skip config query", channel)
}

Try / catch

resp, err := client.Send(ctx, discovery.NewConfigQuery().AddQuery(channel))
if err != nil {
    if strings.Contains(err.Error(), "failed fetching config") {
        return nil, fmt.Errorf("config unavailable for %s: %w", channel, err) // retry later or use local config block
    }
    return nil, err
}

Prevention

When it happens

Trigger: A discovery client sends a ConfigQuery for a channel whose configuration cannot be retrieved — typically the channel doesn't exist on the peer, the config block can't be read/validated from the ledger, or the underlying config service returns an error.

Common situations: Typo in the channel name in the discovery request; client querying a channel no peer in the discovery pool has joined; channel config corruption or genesis-block issues after network bring-up; querying before the channel is fully created.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/b1f0177d9f812dab. Report an issue: GitHub.