istio/istio · error

config writer has not been primed

Error message

config writer has not been primed

What it means

Guard in ConfigWriter.PrintEndpoints (istioctl/pkg/writer/envoy/configdump/endpoint.go:107): the Envoy endpoints (clusters/load-assignment) view cannot be printed because the writer was never primed. Like every Print* method, PrintEndpoints dereferences c.configDump (via retrieveSortedEndpointsSlice) which is only set by a successful Prime(configDumpBytes) call.

Source

Thrown at istioctl/pkg/writer/envoy/configdump/endpoint.go:107

			result = append(result, addr.GetPath())
			continue
		}
		if internal := addr.GetEnvoyInternalAddress(); internal != nil {
			switch an := internal.GetAddressNameSpecifier().(type) {
			case *core.EnvoyInternalAddress_ServerListenerName:
				result = append(result, fmt.Sprintf("envoy://%s/%s", an.ServerListenerName, internal.EndpointId))
				continue
			}
		}
		result = append(result, "unknown")
	}

	return result
}

func (c *ConfigWriter) PrintEndpoints(filter EndpointFilter, outputFormat string) error {
	if c.configDump == nil {
		return fmt.Errorf("config writer has not been primed")
	}
	dump, err := c.retrieveSortedEndpointsSlice(filter)
	if err != nil {
		return err
	}
	marshaller := make(proto.MessageSlice, 0, len(dump))
	for _, eds := range dump {
		marshaller = append(marshaller, eds)
	}
	out, err := json.MarshalIndent(marshaller, "", "    ")
	if err != nil {
		return err
	}
	if outputFormat == "yaml" {
		if out, err = yaml.JSONToYAML(out); err != nil {
			return err
		}
	}

View on GitHub (pinned to 8dc789c5cf)

Solutions

  1. Fetch the pod's /config_dump and Prime the writer, checking the error, before printing endpoints
  2. Centralize prime-then-print in one helper so no Print* can be reached un-primed
  3. Treat a Prime failure as fatal for that pod instead of continuing with an empty writer

Example fix

// before
cw := configdump.NewConfigWriter(os.Stdout)
cw.PrintEndpoints(configdump.EndpointFilter{}, "json") // not primed

// after
if err := cw.Prime(dump); err != nil {
    return err
}
return cw.PrintEndpoints(configdump.EndpointFilter{}, "json")
Defensive patterns

Strategy: validation

Validate before calling

if len(dumpBytes) == 0 {
    return errors.New("no config dump fetched; cannot print endpoints")
}
if err := cw.Prime(dumpBytes); err != nil {
    return fmt.Errorf("prime: %w", err)
}
return cw.PrintEndpoints(filter, "json")

Try / catch

if err := cw.PrintEndpoints(filter, output); err != nil {
    if strings.Contains(err.Error(), "has not been primed") {
        return fmt.Errorf("bug: PrintEndpoints before Prime: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling PrintEndpoints / PrintEndpointsSummary on a ConfigWriter whose Prime was skipped or whose Prime errored ('error unmarshalling config dump response from Envoy') with the error swallowed. This is the path behind `istioctl proxy-config endpoint <pod>`.

Common situations: Programmatic reuse of the writer where a fetch failure is ignored; integrating configdump printing into another tool that constructs the struct directly.

Related errors


AI-assisted analysis of istio/istio@8dc789c5cf (2026-08-15). Data as JSON: /api/errors/45968288cddb9696. Report an issue: GitHub.