kubernetes/kops · error

error building Akamai (Linode) label filter: %w

Error message

error building Akamai (Linode) label filter: %w

What it means

ListOptionsForLabel builds a linodego.Filter for exact label matching and serializes it to JSON. If filter.MarshalJSON fails, the error is wrapped as 'error building Akamai (Linode) label filter: %w'. Used by Find and resource listing for instances, volumes, and VPCs.

Source

Thrown at upup/pkg/fi/cloudup/linode/cloud.go:172

func (c *Cloud) Region() string {
	return c.region
}

func (c *Cloud) FindClusterStatus(cluster *kops.Cluster) (*kops.ClusterStatus, error) {
	return &kops.ClusterStatus{}, nil
}

func (c *Cloud) GetApiIngressStatus(cluster *kops.Cluster) ([]fi.ApiIngressStatus, error) {
	return nil, nil
}

// ListOptionsForLabel builds Akamai (Linode) list options that filter by an exact label match.
func ListOptionsForLabel(label string) (*linodego.ListOptions, error) {
	filter := &linodego.Filter{}
	filter.AddField(linodego.Eq, "label", label)
	filterJSON, err := filter.MarshalJSON()
	if err != nil {
		return nil, fmt.Errorf("error building Akamai (Linode) label filter: %w", err)
	}

	return &linodego.ListOptions{Filter: string(filterJSON)}, nil
}

// ListOptionsForTags builds Akamai (Linode) list options that filter by an exact tag match.
func ListOptionsForTags(tags ...string) (*linodego.ListOptions, error) {
	filters := make([]linodego.FilterNode, 0, len(tags))
	for _, tag := range tags {
		filters = append(filters, &linodego.Comp{Column: "tags", Operator: linodego.Contains, Value: tag})
	}
	filter := linodego.And("", "", filters...)
	filterJSON, err := filter.MarshalJSON()
	if err != nil {
		return nil, fmt.Errorf("error building Akamai (Linode) tag filter: %w", err)
	}

	return &linodego.ListOptions{

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped %w error to identify why MarshalJSON failed.
  2. Confirm the linodego dependency version matches kops' go.mod (run `make gomod`) and rebuild.
  3. Validate the label argument (non-empty, standard Linode label charset [A-Za-z0-9_-]) before calling ListOptionsForLabel.
Defensive patterns

Strategy: try-catch

Validate before calling

func validLinodeLabel(l string) bool {
	valid := regexp.MustCompile(`^[A-Za-z0-9_-]+$`)
	return l != "" && valid.MatchString(l)
}

Type guard

func validLinodeLabel(l string) bool { return l != "" && regexp.MustCompile(`^[A-Za-z0-9_-]+$`).MatchString(l) }

Try / catch

opts, err := ListOptionsForLabel(label)
if err != nil {
	return fmt.Errorf("cannot list resources: %w", err) // inspect wrapped MarshalJSON cause
}

Prevention

When it happens

Trigger: Calling ListOptionsForLabel (directly or via Find/TestListResources) when linodego's Filter MarshalJSON returns an error — typically only with an invalid/mismatched filter state or an incompatible linodego version.

Common situations: Custom code or tests constructing filters with unsupported field types; linodego library version drift where MarshalJSON behavior changed; labels containing characters that break filter construction.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/4051285d9d621d50. Report an issue: GitHub.