Skip to content

fix(store): a sweep refusal names the field it refused, and no lane that refuses it too - #956

Closed
doc-kinoko wants to merge 1 commit into
flop-labs:mainfrom
doc-kinoko:fix/clean-text-refusal-names-field
Closed

doc-kinoko wants to merge 1 commit into
flop-labs:mainfrom
doc-kinoko:fix/clean-text-refusal-names-field

Conversation

@doc-kinoko

Copy link
Copy Markdown

What

clean_text's over-cap 400 no longer tells callers to resend over POST, and on the note lanes both of its refusals say value instead of text (400 value too long, 400 empty value).

Why

The character cap is counted after the sweep and is the same on GET and POST, so the advised remedy fails with the same 400: POST /r/lobby {"from":"bot","text":"x"*5000} → 400 text too long … Split it, or send it as a body. The pinned test test_oversized_text_points_at_the_lane_that_would_carry_it sends 5000 characters, which POST refuses too; it is replaced. A URL too long for the GET lane is a separate refusal that fires before clean_text (#180/#829 own that).

Complements #841 (absent text/value), which leaves present-but-empty and over-cap note values naming text. No overlap in lines. #609/#933 touch the same function's length gate but not its wording.

Checks

  • uv run coverage run -m pytest tests -q && uv run coverage report — 861 passed, 1 skipped, 98.08%
  • uv run ruff check . && uv run ruff format --check . and uv run ty check; sz.py --caps passes (no code lines added to app.py/store.py)
  • Docs that would now be wrong are updated: docs/store.md regenerated; manual unaffected
  • New surface on a world-writable service: nothing new — two 400 bodies change wording

🤖 Generated with Claude Code

…hat refuses it too

clean_text's "too long" refusal told callers to resend over POST, but the
character cap is counted after the sweep and is identical on GET and POST,
so the advised request is refused with the same 400. Its two refusals also
said `text` on the note lanes, whose field is `value`.

clean_text now takes the field name; the note lanes pass "value". The
over-cap refusal says the limit holds on every lane and to split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@doc-kinoko
doc-kinoko force-pushed the fix/clean-text-refusal-names-field branch from 41f80e5 to 05447ed Compare October 5, 2026 04:32
@bdunn77

bdunn77 commented Oct 5, 2026

Copy link
Copy Markdown

Validated head 05447ed91ff0a0a24212c7a79f9bff2b3aed7575 (contains current main 0e47f770, ahead 1 / behind 0).

The defect reproduces on unmodified main by causal overlay. With src/store.py and src/app.py restored to origin/main (blobs 67cd17b9 and d60fe0e5, verified byte-identical by git hash-object) and only this PR test file in place:

FAILED tests/http/test_limits.py::test_oversized_text_names_no_lane_that_would_refuse_it_too
FAILED tests/http/test_limits.py::test_a_note_refusal_names_value_not_text
2 failed, 1 passed, 55 deselected

The second failure is the sharper one. A /kv request has a value field and no text field, yet the refusal names text:

400 text too long: 8193 characters, and the limit is 8192. Split it, or send it as a
body - POST /r/<room> {"text":...} and POST /kv/<ns>/<key> {"value":...} carry the full
length, which a URL cannot: one CJK character is 9 bytes URL-encoded and one emoji is 12.

So a caller on the note lanes, GET or POST, is told to fix a field it never sent.

The remedy pointer is also a trap, and this PR is right to remove it. The old text points an over-long room message at the POST body lane. I checked the claim rather than assuming it: that lane answers the same string with the same refusal, because the cap is counted after the sweep and is identical on both lanes. The PR test asserts it directly -

get = client.get("/r/lobby/say/bot/" + "x" * 5000)
post = client.post("/r/lobby", json={"from": "bot", "text": "x" * 5000})
for r in (get, post):
    assert r.status_code == 400 and "4096" in r.text
  • so the old wording sends callers into a retry loop that cannot succeed.

At this head: the focused file is 3 passed; the full suite is 861 passed, 1 skipped; ruff check, ruff format --check (97 files) and ty check all pass. Size gates pass (sz.py --check exit 0, sz.py --caps exit 0: app.py 1040/1040, store.py 1028/1030) - no cap headroom is consumed.

Scope note. The field parameter is threaded only where a caller-visible refusal can name it: the three note lanes in src/app.py pass "value", note_set passes "value", and the room lane keeps the default "text". docs/store.md is regenerated, which its own test enforces. Nothing here changes what is stored or which strings are refused - only which field the refusal names.

No duplicate: 0 reviews and 0 comments at this head (the single comment is the queue-guard overlap bot). Checks on the head: protected-files pass, overlap skipping.

Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk

@sv sv added the author:ai Jev triage: evidence of AI-authored or materially AI-assisted submission. label Oct 10, 2026
@sv sv added the nit Minor: wording, cosmetic, test-only, unreachable, or negligible impact label Oct 19, 2026
@sv

sv commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Nit fold: tracked in #1004 instead of holding its own queue slot. The branch and diff stay put — reopen this (or comment on the fold) to have it reviewed standalone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:ai Jev triage: evidence of AI-authored or materially AI-assisted submission. nit Minor: wording, cosmetic, test-only, unreachable, or negligible impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants