Repository navigation
client: a host refusal with an empty message is thrown as an empty error, so the row settles on Loading… - #2414
Conversation
`??` keeps an empty string, so a refusal whose `message` was '' was thrown
as `new Error('')`: every surface that prints `error.message` drew nothing,
and the memory row — whose sentence tests the failure for truth — settled on
"Loading…" for a read that had already failed.
Answer the empty message with `Request failed` on both the thrown error and
the noted copy, the sentence already in i18n for zh. A non-empty host
sentence is unchanged.
Fixes ThinkFlowLab#2411
ab2062d to
a0386f4
Compare
|
@Birfy review request — As of my read (GitHub Independent advisory (FlyBot Test) at this exact tip says PASS: red first on clean The change itself is two characters' worth of behaviour: |
Fixes #2411
Owner: Dev-2
Written-by: Dev-2
Reviewer: Birfy
Claim-Id: e243cc9423004c24930321eb7fe1816c
Branch: dev/2-api-empty-error-message
Tip: a0386f4
Tree: 377cc239d5a54b30e66bdf85d888248ef68491b1
Base: 67aead2
Diff: 8 files, +344/−11 (hand-written 4 = +165/−3; generated 4 = +179/−8)
Tier: T1 (why: [])
What changed
core/src/client/api.js:38read a host refusal's message with a nullish fallback:hostText(result.error?.message ?? 'Request failed'). An empty string is not nullish, so??kept it,hostText('')returned'', and the client threwnew Error('')— every surface that printserror.messagedrew nothing. On the memory row it was worse:memoryCountTexttestsif (failure), so an empty reason is falsy,countstaysundefined, and the row settles onLoading…for a read that had already failed.Both places now fall back with
||— the thrown error at:38and the diagnostics copy at:41— so an empty host message readsRequest failed('Request failed': '请求失败'is already ini18n.js, so no new key and not()wrapper, which would change the English path). A non-empty host sentence is passed through byte-for-byte, anderror.code/error.detailsstill pass through.core/src/host/**is untouched.Rebased onto
67aead26(after#2408and#2405); the generatedclient.jsand the0008/0012patches were rebuilt withnpm --prefix core run build+node scripts/ds-bot-patches.mjs generate, not hand-edited.#2408's newrole="status"note below the row draws the samememoryCountTextsentence, so it now announces the refusal instead ofLoading…; its truth guard for an empty failure stays in P-538, as agreed, and is not touched here.Red first
On a clean
67aead26worktree with onlycore/test/api-empty-message.test.jsadded, the file was 5 tests / 1 pass / 4 fail / 0 cancelled (logtmp/p2411-red-67aead26.log,exit 1):bot/refused+message: ''→error.message === ''("an empty host message must not become an empty error");bt-mem-row-copytext wasLoading…("a settled failure never draws the pending text");bot/error+message: ''→ the thrown copy was''and the diagnostics line ended inmemory/view:(empty sentence after the separator);bot/internal+message: ''→ the sentence was' Settings → Feedback has the details.'(leading space).The one passing test is the non-empty host sentence, kept as a regression guard. With the fix the file is 5 / 5 / 0 / 0 on the same base.
Ran
4831 = 2844+570+132+140+411+671+37+26, 0 fail / 0 cancelled; lint 0 errors (core 76 warnings, plugins 36/9/2/16);
arch-docs: OK (8 changed file(s)); 10 patches apply cleanly andcore/equals ds-bot + patches;build-client --checkexit 0 (client.js is the build of src/client); changelog 30 fragments well formed; empty-catch exit 0; mojibake 0 U+FFFD in 1464 text files;generatea no-op on the second run andcanonicalok.Not run
The smoke test (this touches neither
index.jsnorsrc/host/), the pack check / typecheck / actionlint of CI'spackagejob, and CI itself.Docs:
docs/subsystems/core-client.md— the error-toast bullet now states the transport fallback and namescore/test/api-empty-message.test.js.Rebased onto the new main on the Lead's instruction; kept as a draft until the Lead sends it to Test.
{
"pr": 2414,
"claim": "Dev-2",
"issue": 2411,
"summary": "api.js read a host refusal's message with a nullish fallback, so an empty message survived as new Error('') and every surface printing error.message drew nothing; the memory row settled on Loading… for a read that had already failed. Both the thrown error and the diagnostics copy now fall back with ||, so an empty host message reads Request failed, a sentence already in i18n; a non-empty sentence, the code and the details are unchanged. Five tests cover both branches, the row, the leading space and the non-empty pass-through. Rebased onto 67aead2 with the bundle and patches regenerated.",
"files": [
"changelog.d/2411-client-empty-error-message.fixed.md",
"core/client.js",
"core/src/client/api.js",
"core/test/api-empty-message.test.js",
"docs/subsystems/core-client.md",
"patches/ds-bot/0008-client-bundle.patch",
"patches/ds-bot/0012-room-membership.patch",
"patches/ds-bot/files/test/api-empty-message.test.js"
],
"checks": {
"ran": "TZ=UTC ARCH_DOCS_BASE=67aead26 npm run verify",
"result": "green",
"at": "a0386f4d773dca6e914530c67d5cf89a3c8d1463"
},
"next": "draft on purpose; rebased onto 67aead2, waiting for the Lead to send it to Test"
}