beads · issue #7539 · review-and-land plan · pinned at e226083 (29 Oct 2026)
Land #7544 now: it fixes every input in the report. NUL and combining marks need one more small lexer change.
#7544 makes the bd query lexer decode UTF-8 instead of reading each byte as a character, which also repairs a main-only regression in bd show --current for non-ASCII names. CI is green and it merges cleanly into today's main, but it never got the review-pipeline label, and no release has the fix. Of julianknutsen's five extra cases, the digit case already ends in a clear error.
Maintainer view
For the maintainer
Biggest risk this adds
Input that is not UTF-8 changes meaning, and #7544 picks the rule.
Today each byte is read as the Latin-1 character with the same number, so a quoted Latin-1 value becomes UTF-8 and matches (bottom row). After #7544 those bytes are a lex error when bare and copied raw when quoted; a raw byte cannot find the text meant, because every Dolt bd accepts (2.6.0 and 2.6.1 on 29 Oct) keeps no invalid UTF-8 in labels or titles. Rare where locales are UTF-8; unmeasured.
Mitigation: answer Q1 before the next release. If "error", the follow-up (or #7544, if Q3 folds in) flips the quoted invalid-byte test and changelog clause, and both forms fail loudly. Either way, add step 2's bare-byte test.
Your call Q1Should invalid UTF-8 inside a quoted value be an error, or be passed through raw? Suggested: an error, as bare values already are at #7544's head. Dolt's SQL engine, in every release bd accepts (2.6.0 and 2.6.1 on 29 Oct), keeps no invalid UTF-8 in VARCHAR columns (strict mode rejects it, otherwise it cuts the value at the first bad byte), so a raw byte cannot find the text the user meant. Cost: bd show --current then fails for an actor name that is not UTF-8. Not read: out-of-tree backends. Not a merge blocker, because #7544's changelog line is unreleased. Q2Who reviews and merges #7544? Both approvals are from bee-ghosttrack, an agent account, and PR_MAINTAINER_GUIDELINES.md L110 asks for a human review. #7540 and #7375 had the same approvals and merged within about six hours of julianknutsen applying status/needs-review-auto on 16 Oct; both were p0, #7544 is p1. Q3Follow-up PR under a new issue, or fold the extra cases into #7544? Suggested: a follow-up, with its issue filed before #7544 merges, because #7544's "Closes #7539" would otherwise close the only record of the cases. Folding in grows the diff that #7544's pending human review must cover, and CONTRIBUTING asks for one PR per issue (L198). julianknutsen offered either. Q4Backport to a 1.3.x hotfix? Suggested: only if one is planned anyway. Hotfixes are release branches cut from a tag (RELEASING.md L762–768), and #7544's fix commit conflicts with v1.3.2's lexer, so a backport is a hand port. The show --current regression never reached a release. Beyond the issue
- #7544 never entered the merge pipeline. It has only
kind/bugandpriority/p1. #7540 and #7375, with the same agent-only approvals, merged within hours of a maintainer applyingstatus/needs-review-auto. CONTRIBUTING.md L32–46 · #7540 · #7375 - It merges cleanly into today's
main, and no release has the fix. v1.3.2 (24 Oct) was tagged from a release branch and still reads bytes; #7544's fix commit conflicts with its lexer. v1.3.2 lexer.go L112 · RELEASING.md L89–122 - The NUL case cannot come from the command line. argv cannot hold a NUL byte, but
GET /v0/beads/issues:queryhandsqto the lexer unchecked. query.go L154 · reads.go L620 - The digit case is already a clear error, and the proposed digit rule would break
label=١٢٣, which #7544 makes work. evaluator.go L225–228 · lexer.go L349–351 bd show --currentregressed onmainon 13 Oct. #7528 routed it through the query lexer, quoting the actor (by defaultgit config user.name) intoassignee="…". A name like José now misses the claim and falls back to the last-touched issue, exit 0; v1.3.2 filters directly and works. current.go L55 · v1.3.2 L307–312 · #7528
Contributor guide
For whoever lands it
#7544 allows maintainer edits, so changes go on its branch (PR_MAINTAINER_GUIDELINES.md L22); the fitting outcome is Merge or Merge-fix (L79–80), after a human review (L110). An agent that drafts the follow-up needs a human who stands behind it, end-to-end evidence and the PR preflight (AGENTS.md L41–52), and signs per AGENT_SIGNING.md.
1 · #7544: keep, change, drop
| Part of #7544 | Verdict | Why |
|---|---|---|
next() and peek() decode with utf8.DecodeRuneInString; l.width is the decoded size | Keep | The root cause of all four reported inputs and of --parse-only. |
acceptDuration steps by rune (in the merge commit) | Keep | The issue's third byte read moved: #7683 replaced that lookahead with acceptDuration's loop (lexer.go L374), and the merge commit fixes the loop. |
readString and readIdent copy the consumed bytes | Keep | Valid text is unchanged either way. The quoted invalid-byte behaviour is Q1's to settle in the follow-up. |
Seven TestLexer rows | Keep | All seven fail on main. The position row fails through its value; its positions guard whole-rune backup(). |
| CHANGELOG line | Change one clause | "invalid bytes inside a value pass through unchanged" holds only inside quotes: at 91f8f7f a bare invalid byte is a lex error. Say "inside a quoted value", or state Q1's answer. Lands under [Unreleased]. |
| PR body | Change | Make "Closes #7539" match Q3, or the merge closes #7539 with the NUL and combining-mark cases open. The body also says invalid UTF-8 "inside a value" passes through, which holds only inside quotes; the body must match the diff (L106). |
2 · Two test rows worth adding (to #7544 or the follow-up)
| Test (proposed, not run) | Asserts | Today on main |
|---|---|---|
TestFindCurrentIssueQueryMeansTheRawFilter: add "José" to its actors (current_test.go L136) | Through FindCurrentIssue and BuildQueryPlan, the filter's assignee equals the actor | Fails: José |
TestParser: label="größe" and title='日本語' | node.String() keeps each value (label=größe, title=日本語), which is what --parse-only prints (query.go L193) | Fails: mojibake |
TestLexerErrors: bare label=f\xeate (Latin-1 ê) | An error (the table checks only that one occurs) | Fails: lexes as fête. Pins the risk above |
3 · The remaining lexer changes, R1–R4
Suggested as a follow-up PR under its own issue (Q3), built on #7544's head. Reuse the fork's test inputs, not its commits: both patch a lexer that still has isDurationSuffix, which #7683 removed on 19 Oct, and d9a2e64b6 touches 153 files. Files: internal/query/lexer.go, internal/query/query_test.go, CHANGELOG.md. Keep the tests in query_test.go: a new test file has to be added to BUILD.bazel with make bazel-sync. TestLexer stops at any error (L218–223), so error rows go in an exact-message table like L852–871.
| Requirement | Change in lexer.go | Proposed test (fails on #7544's head unless marked) |
|---|---|---|
| R1 · A NUL never ends a query early or vanishes from it | next() and peek() return an eof of −1 (L113, L124 at #7544's head); the eight end-of-input checks at L139, L153, L204, L224, L281, L292, L299 and L312 compare with it; a decoded U+0000 is unexpected NUL at position N in NextToken, in readString and after a backslash | label=ab\x00 OR status=closed → error with unexpected NUL (today: IDENT(ab), EOF) · title="ab\x00cd" → unexpected NUL at position 9 (today: unterminated string) · title="ab\+NUL → unexpected NUL (today: unterminated escape) · priority=1\x00 OR status=closed → unexpected NUL at position 10 (today the number scan swallows the NUL at L299 and the query runs as priority=1 OR status=closed) · control: title="ab keeps unterminated string starting at position 6 |
| R2 · Combining marks continue a bare value | isIdentChar (L361–362 at #7544's head) also accepts unicode.Mn and unicode.Mc; isIdentStart unchanged | label=cafe\u0301 and label=हिन्दी → one IDENT each, value unchanged · control: label=\u0301x still errors, since a mark cannot start a value |
| R3 · Invalid UTF-8 follows Q1 | If "error": readString refuses a width-1 utf8.RuneError, with its byte position, in the plain branch and in the escape branch's default case (L226–227 at #7544's head) | Flip #7544's title="a\xffb" row to expect an error; add title="a\+\xff+b" (today copied raw); reword the changelog clause |
| R4 · Values #7544 fixed stay fixed | Leave digits as #7544 has them. If NUMBER must be ASCII-only, let a non-ASCII digit start an identifier rather than fail | Guard, passes on #7544: label=١٢٣ → one value · priority=٣ still fails with invalid priority value: ٣. updated>٣d reaches the time parser as an identifier, since the duration pattern is ASCII-only (parser.go L22); its natural-language step is not traced |
End-to-end evidence for the follow-up's PR body (AGENTS.md L41–43): in a workspace on a Dolt SQL server (bd serve refuses embedded Dolt, serve.go L650–653), against a local bd serve, GET /v0/beads/issues:query?q=label%3Dab%00%20OR%20status%3Dclosed returns a 400 naming q (today it answers as label=ab); bd query 'label=café' typed in NFD finds an issue whose label was created in NFD. For #7544 itself: with git config user.name José, claim an issue (bd update <id> --claim), comment on another, then bd show --current shows the claimed one (today: the one commented on).
Commands, from engdocs/TESTING.md and AGENTS.md
scripts/pr-preflight.sh --search "query lexer utf8" --repo gastownhall/beads
bazel test //internal/query:query_test --config=ci --test_filter='^(TestLexer|TestParser)' --test_output=all
bazel test //internal/query/... --config=ci
bazel test //issueops:issueops_test --config=ci --test_filter='^TestFindCurrentIssue' --test_output=all
make test # final gate, once
scripts/gh-body-lint <body-file> # before gh pr create --body-file
Sources: TESTING.md L99–101, AGENTS.md L44–55.
Done when
- #7544 is merged after a human review, with its body fixed and its "Closes" line matching Q3's answer.
- The step-2 rows are on
main, in #7544 or the follow-up. - The R1, R2 and R4 rows pass on
main; R3 and the changelog clause match Q1's answer. - The end-to-end checks above are recorded in the PR bodies.
- No issue tracking these cases closes before its case is fixed on
main. The fix ships in the next release cut frommain, or earlier in a 1.3.x hotfix if Q4 is yes.
Implementation notes
How the reported inputs move through the lexer
| Input | main (byte as rune, L114) | #7544 head |
|---|---|---|
label="größe" | bytes c3 b6 c3 9f read as U+00C3 U+00B6 U+00C3 U+009F and written back by WriteRune (L228) as two bytes each | STRING(größe) |
label=größe | U+00C3 is a letter, U+00B6 is not: IDENT ends, then unexpected character '¶' at position 9 | IDENT(größe) |
label=fête | U+00C3 and U+00AA are both letters: IDENT with the re-encoded value | IDENT(fête) |
label=cafe\u0301 | IDENT ends at byte 0x81, then an error at 11 | IDENT(cafe), then an error at 10 (U+0301 is Mn) |
label=ab\x00 OR … | rune 0 is the end-of-input sentinel (L309, L151): IDENT(ab), EOF | same |
priority=٣ | U+00D9 then U+00A3: error | NUMBER(٣); strconv.Atoi fails: invalid priority value: ٣. Only DURATION changes evaluation (evaluator.go L612), and NUMBER is accepted as a label value (parser.go L284–286) |
Every path into the lexer
| Entry | Reaches query.Parse via | Can carry NUL | Can carry invalid UTF-8 |
|---|---|---|---|
bd query | argv joined (query.go L154) → Querier → BuildQueryPlan (workapi/query.go L81), from both bodies (uow L49, storequerier L42) | No | Yes |
bd show --current | actor from --actor, BEADS_ACTOR or git config user.name (main.go L1033–1053) quoted into status=… AND assignee="…" (current.go L55) → Querier; a miss falls back to the last-touched issue (show_current.go L44–50). Since #7528 on 13 Oct; v1.3.2 builds the filter directly | No | Yes (env) |
bd query --parse-only | query.go L189; no store | No | Yes |
bd query, proxied server | unit-of-work Querier, parsed in process (query_proxied_server.go L23–31 → uow L49) | No | Yes |
bd query, http backend | client sends q (role_querier.go L30–47), then as below | No | Yes |
bd gate list | the constant type=gate (gates.go L50–56) | No | No |
GET /v0/beads/issues:query | routes.go L624 → q unchecked (httpapi/query.go L57–67) → BuildQueryPlan; a Parse error is a 400 on q (reads.go L836–839) | Yes (%00) | Yes |
| beads-mcp | Does not call bd query; its query parameter is a title search (server.py L432) | — | — |
The two follow-up designs in the thread
| Point | julianknutsen (comment, 16 Oct) | BlueboxC fork (d9a2e64b6) | This plan |
|---|---|---|---|
| End of input | eof = -1 | lexerEOF = -1 | Same (R1) |
| Literal NUL | Error anywhere | Error anywhere | Same (R1) |
| Marks | Mn, Mc | unicode.IsMark (adds Me) | Mn, Mc (R2) |
| Invalid UTF-8, quoted | Error | Kept raw | Q1; suggested error |
| Digits | ASCII only | ASCII only | Keep label=١٢٣ working (R4) |
Invalid UTF-8, the three ways. Pass through raw (#7544, the fork): keeps the byte, which no in-tree store can hold. Error (julianknutsen): loud, matches bare values, and turns bd show --current into an error for an actor that is not UTF-8. Decode a stray byte as Latin-1, as main does by accident: keeps a Latin-1 shell working but guesses an encoding byte by byte and cannot tell Latin-1 from damaged UTF-8; nobody in the thread proposed it.
The fork's d3febf1 (4 files) mirrors #7544. d9a2e64b6 is titled "fix: qualify transaction safety and bounded native reads" and changes 153 files (+10,085/−967); its lexer part is +25/−14 plus a new lexer_followup_test.go. Its isDurationSuffix was removed from main by #7683 (present at 4c473b4~1, absent at the pin).
Supporting reads
- Pipeline. On 16 Oct julianknutsen applied
status/needs-review-autoto #7540 at 05:31 and #7375 at 05:32 UTC; gascity-eddie labelled them reviewing, merge-ready and merge-queued, and merged them at 09:04 and 11:35. Of the last 300 merged PRs (created 6–28 Oct), gascity-eddie merged 166 and julianknutsen 128. - #7544 state. Head 91f8f7f merges
mainat d097b6c into 2e3a5f3. Approvals by bee-ghosttrack at 5db86be (13 Oct, with a red/green run and mutants) and 91f8f7f (19 Oct). 34 checks at the head: 28 passed, 6 skipped.git merge-treeinto e226083 is clean;mainis 123 commits past d097b6c. - Dolt keeps no invalid UTF-8 in these columns.
labels.labelandissues.titleareVARCHAR(0003 L3, 0001 L4). go-mysql-server at the version in go.mod L19 rejects invalid UTF-8 for such a column in strict SQL mode and otherwise cuts the value at the first invalid byte (strings.go L524–534, L565–574). That is the engine embedded mode runs. In server mode bd refuses a Dolt older than 2.6.0 (policy.go L44; an undetectable version is let through), and Dolt v2.6.0 pins this same go-mysql-server (dolt go.mod L33); Dolt v2.6.1, the latest on 29 Oct, pins go-mysql-server c22d4b6 (go.mod L33), whosestrings.goL515–580 is the same. - No Unicode normalization anywhere.
NormalizeLabelstrims and deduplicates only (utils/strings.go L25–40). After R2 an NFD value lexes, but it still matches only an NFD-stored value. Zero-width joiners (U+200C, U+200D, category Cf) also still end a bare value after R2; quoting works. Both out of scope here. - Not a superseding design. #7728, a design review for a new query language, is triaged p3 with no implementation.
Unknowns
- Out-of-tree backends. Whether any can store non-UTF-8 text. It affects only the Q1 suggestion for them; a conformance case writing a label with byte
0xffwould answer it. - How many users send non-UTF-8 bytes. Not readable from source. It sizes the risk card, not the fix.
- Why #7544 has no pipeline label. Only a maintainer knows (Q2).
- An invalid byte in a query operand on the SQL path (label equality or the
titlepattern). Not traced: a strict-mode error, or a value cut at the bad byte that could match a different stored value. Moot if Q1 is "error".
Prepared from public sources only: the issue thread, PR #7544 and its reviews, the BlueboxC fork commits, PRs #7540, #7375 and #7683, and the code at e226083, 91f8f7f, v1.3.2 (9b65b9e) and go-mysql-server 38a1fb5. Behaviour was traced by hand; no project code was run, and the tests are proposed, not passed. Nothing was posted to GitHub. enriched by

