{"record":{"id":"fe313b7199f22b80","repo":"gastownhall/beads","slug":"invalid-metadata-field-key-w","errorCode":null,"errorMessage":"invalid metadata field key: %w","messagePattern":"invalid metadata field key: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/workapi/metadata.go","lineNumber":38,"sourceCode":"// it in its own words: this is the floor under every caller, not a replacement\n// for a front door's usage error.\n//\n// Keys are checked in sorted order so a request with two bad keys always names\n// the same one.\nfunc ValidateMetadataFilters(fields map[string]string, hasKey string) error {\n\tif hasKey != \"\" {\n\t\tif err := storage.ValidateMetadataKey(hasKey); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid metadata key filter: %w\", err)\n\t\t}\n\t}\n\tkeys := make([]string, 0, len(fields))\n\tfor k := range fields {\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\tfor _, k := range keys {\n\t\tif err := storage.ValidateMetadataKey(k); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid metadata field key: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":20,"sourceCodeEnd":43,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/workapi/metadata.go#L20-L43","documentation":"ValidateMetadataFilters checks each key of the fields map (in sorted order, so repeated runs name the same first offender) with storage.ValidateMetadataKey and wraps any failure as 'invalid metadata field key'. It exists so field-equality filters get the same key rules as --has-key, with deterministic error output. The inner error carries the concrete violation.","triggerScenarios":"Calling BuildListFilter or BuildReadyFilter where any key in the fields map fails ValidateMetadataKey — bad characters, wrong length, or empty string after trimming.","commonSituations":"Passing metadata filters from a config file where keys were authored free-form; upstream tooling emitting keys with dots or slashes; a key renamed at the source while an old filter still references the old spelling.","solutions":["Fix the first key named by the error (keys are checked alphabetically, so fix-and-rerun iterates through remaining offenders)","Conform keys to ValidateMetadataKey's rules: allowed charset, length, non-empty","Compare against keys present on real issues (`bd show <id>`) to confirm exact spelling"],"exampleFix":"// before\nfields := map[string]string{\"review.status\": \"approved\"}\n// after\nfields := map[string]string{\"review-status\": \"approved\"}","handlingStrategy":"validation","validationCode":"for k := range fields {\n\tif err := storage.ValidateMetadataKey(k); err != nil {\n\t\treturn fmt.Errorf(\"field %q: %w\", k, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"err := ValidateMetadataFilters(fields, hasKey)\nif err != nil && strings.HasPrefix(err.Error(), \"invalid metadata field key\") {\n\treturn fmt.Errorf(\"fix metadata field filters: %w\", err)\n}","preventionTips":["Validate every field-map key with storage.ValidateMetadataKey before building filters","Generate keys from a shared constant set, not free-form config","Re-check filters after any upstream key rename"],"tags":["cli","validation","metadata","filtering"],"backgroundTag":"invalid-metadata-key","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}