{"record":{"id":"4ef736a4df53449e","repo":"gastownhall/beads","slug":"errfieldtoolong","errorCode":"ErrFieldTooLong","errorMessage":"field exceeds maximum length","messagePattern":"field exceeds maximum length","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/types/types.go","lineNumber":292,"sourceCode":"\tw.h.Write([]byte(fmt.Sprintf(\"%d\", d)))\n\tw.h.Write([]byte{0})\n}\n\nfunc (w hashFieldWriter) flag(b bool, label string) {\n\tif b {\n\t\tw.h.Write([]byte(label))\n\t}\n\tw.h.Write([]byte{0})\n}\n\n// MaxFieldLen is the maximum length (in characters) of common bounded text\n// fields, matching their VARCHAR(255) columns.\nconst MaxFieldLen = 255\n\n// ErrFieldTooLong is returned when a bounded text field exceeds MaxFieldLen\n// characters. Callers can errors.Is it instead of matching a raw backend \"data\n// too long\" string.\nvar ErrFieldTooLong = errors.New(\"field exceeds maximum length\")\n\n// CheckFieldLen returns ErrFieldTooLong (wrapped with context) when val exceeds\n// MaxFieldLen characters. name is the field label used in the message. Length is\n// counted in runes, not bytes, so a multibyte value up to MaxFieldLen characters\n// fits the VARCHAR(255) column and passes.\nfunc CheckFieldLen(name, val string) error {\n\tif n := utf8.RuneCountInString(val); n > MaxFieldLen {\n\t\treturn fmt.Errorf(\"%w: %s is %d characters (max %d)\", ErrFieldTooLong, name, n, MaxFieldLen)\n\t}\n\treturn nil\n}\n\n// MaxTextBytes is the maximum size, in BYTES, of a `TEXT` column — the storage\n// ceiling for the values this schema keeps in one rather than in a LONGTEXT.\n//\n// BYTES, NOT CHARACTERS, which is the one place this differs from MaxFieldLen\n// beside it and the reason CheckTextLen does not simply call CheckFieldLen with\n// a bigger number: MySQL and Dolt bound a TEXT column by its encoded length, so","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/types/types.go#L274-L310","documentation":"ErrFieldTooLong is returned when a bounded text field (title, description, etc.) exceeds MaxFieldLen (255) characters, matching the backend VARCHAR(255) columns. CheckFieldLen produces it wrapped with the field name for context. Length is counted in runes, not bytes, so multibyte values up to 255 characters are fine. Callers should errors.Is it rather than matching raw backend 'data too long' strings.","triggerScenarios":"Calling CheckFieldLen (or any create/update path that validates fields) with a title, label, or other bounded string longer than 255 characters; e.g. bd create with an extremely long --title or programmatically passing oversized values to issue create/update.","commonSituations":"Pasting long log excerpts or generated text into the title field; importing issues from another tracker with unbounded field lengths; generating titles from commit messages or URLs that exceed 255 characters.","solutions":["Truncate or shorten the offending field to 255 runes or fewer before calling the API.","Move long content into the description field if it has a larger bound, keeping only a short summary in the title.","Pre-validate with types.CheckFieldLen(name, val) and handle the wrapped error to surface which field was too long.","Do not match raw backend 'data too long' errors; use errors.Is(err, types.ErrFieldTooLong) for classification."],"exampleFix":"// before\nissue.Title = strings.Join(longParts, \" \")\nbd.Create(issue) // fails: field exceeds maximum length\n\n// after\ntitle := strings.Join(longParts, \" \")\nif err := types.CheckFieldLen(\"title\", title); err != nil {\n    title = string([]rune(title)[:255])\n}\nissue.Title = title","handlingStrategy":"validation","validationCode":"if err := types.CheckFieldLen(\"title\", issue.Title); err != nil {\n    return err // too long, fix before calling the API\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, types.ErrFieldTooLong) {\n    // truncate the named field and retry or report\n}","preventionTips":["Cap title/label inputs at 255 runes in UI and CLI layers.","Route long content to unbounded fields (description).","Always classify with errors.Is, never string matching."],"tags":["validation","field-length","input"],"backgroundTag":"field-exceeds-max-length","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}