GeezerVison is showing github.com — grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption · Issue #6588 · developing-today/code
grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption #6588Descriptiongrist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption
Evidence (verified this run, laptop @ 9123103 == origin/main)
pm-stack/grist/update-choice-options.py extends a Grist Choice column's options. It reads the column's widgetOptions JSON, merges additions, PATCHes the result back, and verifies by read-back. Nothing checks the shape of what came back:
merge_choices (:45) does choices = list(merged.get("choices") or []) at :53. If the stored choices is a string, list() shreds it into characters. If it is a list containing non-strings, they pass through unchecked.
get_widget_options (:90) returns json.loads(raw) at :95 verbatim — if the stored widgetOptions JSON parses to a non-object (a string, a list, a number), that value flows straight into merge_choices, where dict(widget_options) raises a raw ValueError. run() (:165) catches only TimeoutError, so the tool dies with a traceback instead of its documented clean exit codes (0 ok / 1 API-or-verification failure / 2 usage).
- The read-back verification in
main (:147) compares read-back choices against the merged value — so a corrupted merge verifies as good. It never compares against the original choices' shape.
Probe (laptop, ~/git/fleet/probe-grist-choices/probe.py, real module imported from the primary tree):
- Control:
merge_choices({"choices": ["code", "infra"]}, ["id"]) → ["code", "infra", "id"] ✔
merge_choices({"choices": "code"}, ["id"]) → ['c', 'o', 'd', 'e', 'id'] — the existing choice code is destroyed and replaced with four one-character choices; main would PATCH this and the read-back check at :147 would pass it.
merge_choices(json.loads('"justastring"'), ["x"]) → uncaught ValueError: dictionary update sequence element #0 has length 1; 2 is required (traceback out of run(), which catches only TimeoutError).
merge_choices({"choices": [1, None, True]}, ["id"]) → [1, None, True, "id"] — non-string choices pass through and would be written back as JSON 1 / null / true choices.
Why it matters
This tool is the supported path for extending Choice columns (#1287): it writes to a live Grist doc and its only safety net is the read-back verification — which compares against the possibly-corrupted merge, not the original data. A widgetOptions value whose choices was written by anything else (a Grist UI change, a manual edit, an older/newer Grist version's serialization, a ChoiceList vs Choice confusion) in a non-list shape is silently destroyed on the next routine --add, with the tool reporting success. The non-object case separately breaks the tool's exit-code contract with a raw traceback.
Acceptance criteria
merge_choices (or its caller) refuses a widgetOptions that is not a JSON object, and a choices value that is not a list of strings, with a clear named error — never a shredded/coerced write and never a raw traceback.
- The refusal happens before any PATCH is sent; the stored column is untouched on a shape failure.
- The CLI surfaces shape failures through its documented exit-code contract (a clean message on stderr and a non-zero exit, like the timeout path in
run()).
- Tests in
pm-stack/grist/test_update_choice_options.py pin: string choices, dict choices, non-object widgetOptions, and a list containing non-string entries — plus the existing controls (normal append, idempotence, empty options, duplicate additions, input not mutated) unchanged.
python3 -m unittest test_update_choice_options green in pm-stack/grist (laptop or CI).
Activitydeveloping-today commented on Nov 6, 2026 dezren39 commented on Nov 6, 2026 🤖 Agent note · filed
- Agent: new-issue-creator (Lane B), agent slug
new-issue-creator-code-b
- Session / ID: cron job
new-issue-creator-code-b, run 2026-11-06 11:50 CST
- Found via: filed this run
- Task: Triage the non-list
choices shape defect in pm-stack/grist/update-choice-options.py — a string choices value is shredded by list() and PATCHed back with read-back verification passing, and a non-object widgetOptions crashes with a raw ValueError traceback
- Expectation: effort/s — done when shape validation refuses non-object widgetOptions and non-list-of-strings choices before any PATCH, with tests pinning the probe cases
- Links: probe ~/git/fleet/probe-grist-choices on the laptop (real module @ 9123103)
dezren39 commented on Nov 6, 2026 🤖 Agent note · triage: CONFIRMED
- Agent: repo queue worker, lane code-t (repo-worker-code)
- Session / ID: cron repo-queue-worker-shift-t run 2026-11-06; task 11318
- Found via: claimed task 11318 this shift (triage of issue grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption #6588); execution-lane assignment returned
direct, so this lane verified it.
- Fresh verification (laptop primary
~/git/code @ 0819afd0fc5a987b1602ab880f204908a2183f08, real module imported):
- Control:
merge_choices({"choices": ["code", "infra"]}, ["id"]) → ["code", "infra", "id"] ✔
- String choices:
merge_choices({"choices": "code"}, ["id"]) → ['c', 'o', 'd', 'e', 'id'] — shredding reproduced exactly as filed.
- Non-object widgetOptions:
merge_choices(json.loads('"justastring"'), ["x"]) → uncaught ValueError: dictionary update sequence element #0 has length 1; 2 is required (run() catches only TimeoutError).
- Non-string entries:
merge_choices({"choices": [1, None, True]}, ["id"]) → [1, None, True, "id"] — pass through unchecked.
- New datapoint (not in the original filing): dict choices
merge_choices({"choices": {"a": 1}}, ["id"]) → ['a', 'id'] — a dict is silently replaced by its keys. Same defect class; the routed fix's tests already pin the dict case.
- Source confirms the mechanism on current main:
list(merged.get("choices") or []) at pm-stack/grist/update-choice-options.py:53; get_widget_options returns json.loads(raw) verbatim; read-back in main compares against the merged value.
- Verdict: CONFIRMED, live on current main, no hard-stop labels. Routed as a single small_fix follow-up task (dedupe
repo-health:v1:fix:developing-today/code:issue:6588) carrying issue grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption #6588's acceptance criteria verbatim. Task 11318 completes as triaged.
- Links: task 11318 · issue grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption #6588
dezren39 commented on Nov 7, 2026 🤖 Agent note · picked up
- Agent: queue worker (repo-worker-code), lane code-i
- Session / ID: repo-queue-worker-shift-i, 2026-11-06 20:28 CST — FALLBACK MODE (queue backend down:
fleet queue health HTTP 503 PGRST002, exit 4; outage tracked as issue infra: repo-queue PostgREST timeout: global failures lane-visible again — recurrence after #6450 closed (2026-11-06 21:15-21:31Z) #6619). Fallback claim on issue grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption #6588; lane code-p released it free earlier and this lane claimed it fresh after that release.
- Found via: fallback scan (claimable, released/free)
- Task: Add shape validation to
pm-stack/grist/update-choice-options.py: refuse a non-object widgetOptions and a non-list-of-strings choices with a named error before any PATCH, surfaced through the documented exit-code contract (clean stderr, exit 1 via run()), with tests pinning the probe cases from this issue.
- Expectation: effort s — script fix + tests in
pm-stack/grist/test_update_choice_options.py, branch + PR, merge under the standing criteria if verified.
- Links: branch
queue/fallback-6588-grist-choices-shape, laptop worktree ~/git/fleet/fb-6588
dezren39 commented on Nov 7, 2026
Progress from repo-worker-code-i: picked up: script and existing tests read on current main; fix = WidgetOptionsError shape validation in merge_choices + get_widget_options, run() maps it to exit 1 before any PATCH; next: laptop worktree + implementation dezren39 commented on Nov 7, 2026
Progress from repo-worker-code-i: pr_opened: PR for issue #6588 opened (branch queue/fallback-6588-grist-choices-shape, commit fc49b8d); unittest 15/15 green on laptop, pre-fix suite fails (1 failure + 8 errors); next: PR checks + Codex, then merge under standing criteria dezren39 commented on Nov 7, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), lane code-i
- Session / ID: repo-queue-worker-shift-i, 2026-11-06 20:28 CST — FALLBACK MODE (queue backend down, issue infra: repo-queue PostgREST timeout: global failures lane-visible again — recurrence after #6450 closed (2026-11-06 21:15-21:31Z) #6619); fallback claim on issue grist(update-choice-options): a non-list choices value is silently shredded or crashes the tool — a string choice becomes one-character choices and the read-back verification passes the corruption #6588
- Found via: fallback scan (claimable; released free by lane code-p, claimed fresh after)
- Task: Add shape validation to
pm-stack/grist/update-choice-options.py so a malformed stored widgetOptions/choices is refused by name before any PATCH.
- Outcome:
fixed_merged — PR grist(update-choice-options): refuse widgetOptions/choices shape failures by name (#6588) #6719 merged (merge commit ae31c5d); this issue auto-closed by the merge.
- New
check_widget_options + WidgetOptionsError: stored widgetOptions must be a JSON object and choices (when present, non-null) a list of strings; merge_choices and get_widget_options both validate (invalid JSON included), so refusal happens before any PATCH is built and the stored column is untouched on a shape failure.
run() maps the error to a clean stderr message + exit 1, matching the documented exit-code contract (the timeout path's shape). Null/absent choices keep their existing no-choices meaning.
- Tests:
python3 -m unittest test_update_choice_options — 15/15 green on the laptop, including new merge-level cases (string/dict choices, non-object widgetOptions, non-string entries) and CLI-level cases pinning exit 1 with zero PATCHes sent. Against the pre-fix script the suite fails (1 failure + 8 errors) and prints the shredding it prevents (code -> ['c', 'o', 'd', 'e', 'id']).
- Codex review on PR grist(update-choice-options): refuse widgetOptions/choices shape failures by name (#6588) #6719: zero findings. PR checks (scripts-test) still QUEUED at merge (runner backlog) — merged under the standing criteria on the laptop verification above.
- Links: PR grist(update-choice-options): refuse widgetOptions/choices shape failures by name (#6588) #6719 grist(update-choice-options): refuse widgetOptions/choices shape failures by name (#6588) #6719 · branch
queue/fallback-6588-grist-choices-shape
dezren39 commented on Nov 7, 2026
Released by repo-worker-code-i (outcome: done). Outcome: fixed_merged. PR #6719 merged (merge commit ae31c5d); issue #6588 auto-closed. update-choice-options.py now validates stored widgetOptions/choices shape via check_widget_options/WidgetOptionsError before any PATCH (string choices refused, not shredded; non-object and invalid-JSON refused by name), surfaced as clean stderr + exit 1 via run(). Tests 15/15 green on laptop; pre-fix suite fails (1 failure + 8 errors). Codex zero findings on PR #6719.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|