{"record":{"id":"4051285d9d621d50","repo":"kubernetes/kops","slug":"error-building-akamai-linode-label-filter-w","errorCode":null,"errorMessage":"error building Akamai (Linode) label filter: %w","messagePattern":"error building Akamai \\(Linode\\) label filter: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/linode/cloud.go","lineNumber":172,"sourceCode":"func (c *Cloud) Region() string {\n\treturn c.region\n}\n\nfunc (c *Cloud) FindClusterStatus(cluster *kops.Cluster) (*kops.ClusterStatus, error) {\n\treturn &kops.ClusterStatus{}, nil\n}\n\nfunc (c *Cloud) GetApiIngressStatus(cluster *kops.Cluster) ([]fi.ApiIngressStatus, error) {\n\treturn nil, nil\n}\n\n// ListOptionsForLabel builds Akamai (Linode) list options that filter by an exact label match.\nfunc ListOptionsForLabel(label string) (*linodego.ListOptions, error) {\n\tfilter := &linodego.Filter{}\n\tfilter.AddField(linodego.Eq, \"label\", label)\n\tfilterJSON, err := filter.MarshalJSON()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error building Akamai (Linode) label filter: %w\", err)\n\t}\n\n\treturn &linodego.ListOptions{Filter: string(filterJSON)}, nil\n}\n\n// ListOptionsForTags builds Akamai (Linode) list options that filter by an exact tag match.\nfunc ListOptionsForTags(tags ...string) (*linodego.ListOptions, error) {\n\tfilters := make([]linodego.FilterNode, 0, len(tags))\n\tfor _, tag := range tags {\n\t\tfilters = append(filters, &linodego.Comp{Column: \"tags\", Operator: linodego.Contains, Value: tag})\n\t}\n\tfilter := linodego.And(\"\", \"\", filters...)\n\tfilterJSON, err := filter.MarshalJSON()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error building Akamai (Linode) tag filter: %w\", err)\n\t}\n\n\treturn &linodego.ListOptions{","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/linode/cloud.go#L154-L190","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped %w error to identify why MarshalJSON failed.","Confirm the linodego dependency version matches kops' go.mod (run `make gomod`) and rebuild.","Validate the label argument (non-empty, standard Linode label charset [A-Za-z0-9_-]) before calling ListOptionsForLabel."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"func validLinodeLabel(l string) bool {\n\tvalid := regexp.MustCompile(`^[A-Za-z0-9_-]+$`)\n\treturn l != \"\" && valid.MatchString(l)\n}","typeGuard":"func validLinodeLabel(l string) bool { return l != \"\" && regexp.MustCompile(`^[A-Za-z0-9_-]+$`).MatchString(l) }","tryCatchPattern":"opts, err := ListOptionsForLabel(label)\nif err != nil {\n\treturn fmt.Errorf(\"cannot list resources: %w\", err) // inspect wrapped MarshalJSON cause\n}","preventionTips":["Keep linodego aligned with kops go.mod so Filter.MarshalJSON behaves as expected","Sanitize labels to [A-Za-z0-9_-] before filtering (kops provides invalidLinodeLabelChars regex)","Unit-test filter construction when upgrading linodego versions"],"tags":["linode","akamai","filter","json-marshaling"],"backgroundTag":"filter-serialization-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}