Repository navigation
Say when an answer is too long to store - #294
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PhilReinking
left a comment
There was a problem hiding this comment.
Changes at e138013, CI green. Must-fix inline: the message shows on the wrong page. The rest holds in Brave with #293 merged: a 70,000-character answer gets a 422 on payload., the form shows the new text in English and German, it fits at 390 px, and a shortened answer then saves. Reading the key is OK: only the size rules write to payload., so no server code is needed. The 6 new translations read like submit_failed. Vitest 526 pass.
| this.submitTooLong = | ||
| response?.status === 422 && | ||
| Object.keys(response.data?.errors ?? {}).some( | ||
| (field) => field.startsWith("payload."), | ||
| ); |
There was a problem hiding this comment.
When the long answer is on an earlier page, this message shows on the last page, under an answer that is fine. In Brave at e138013 with #293 merged: 70,000 characters in question 1, "short" in question 2, Submit → 422 on payload.<question 1>, and question 2 says "This answer is too long" under its 5 / 100 answer. The visitor may shorten the wrong answer and send again.
The key names the question, so the form can go back to its page. That answer is always on path or the current page, since submittablePayload sends only those:
const tooLong =
response?.status === 422
? Object.keys(response.data?.errors ?? {})
.find((field) => field.startsWith("payload."))
?.slice("payload.".length)
: undefined;
this.submitTooLong = tooLong !== undefined;
// show the message on the too long answer's page: back along the path to it
if (tooLong && this.path.includes(tooLong)) {
while (this.current !== tooLong) {
this.back();
}
}A Block test with two questions would cover it. I did not run this code.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PhilReinking
left a comment
There was a problem hiding this comment.
Changes at d6701ae, CI green. Must-fix inline: when the jump is skipped, no message shows at all. The rest holds in Brave with #293 (cc75cd9) merged, at 390 px: a too-long Q2 of 3 jumps back to Q2 with the message; forward to Q3 shows none, back to Q2 shows it again; the shortened answer then saves. A too-long answer on the current page shows in place, in German too. Vitest 527 pass.
| if ( | ||
| onPath !== -1 && | ||
| this.tooLongBlock && | ||
| this.findBlockIndex(this.tooLongBlock) !== -1 | ||
| ) { | ||
| this.current = this.tooLongBlock; | ||
| this.path = this.path.slice(0, onPath); | ||
| } |
There was a problem hiding this comment.
When the jump is skipped, the visitor sees nothing. tooLongBlock then names a question that isn't on this page, so Block.vue hides the message here too. In Brave, with a faked 422 on payload.notablock, Submit on the last page stopped spinning and no text showed. Today the form only sends answers from the path, so this needs a changed key (say a nested payload.<id>.0). But then it fails silently. Say it on this page instead:
| if ( | |
| onPath !== -1 && | |
| this.tooLongBlock && | |
| this.findBlockIndex(this.tooLongBlock) !== -1 | |
| ) { | |
| this.current = this.tooLongBlock; | |
| this.path = this.path.slice(0, onPath); | |
| } | |
| if ( | |
| onPath !== -1 && | |
| this.tooLongBlock && | |
| this.findBlockIndex(this.tooLongBlock) !== -1 | |
| ) { | |
| this.current = this.tooLongBlock; | |
| this.path = this.path.slice(0, onPath); | |
| } else if (this.tooLongBlock) { | |
| // no page of its own to go back to: say it on this one | |
| this.tooLongBlock = this.current; | |
| } |
I did not run this.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PhilReinking
left a comment
There was a problem hiding this comment.
OK at e5eff4c, CI green. The must-fix holds in Brave with #293 (5bf280a) merged, at 390 px: with a faked 422 on a question not on the path, the last page now shows the too-long text in place. The jump still works: a too-long Q2 of 3 jumps back to Q2 with the message, and the shortened answer then saves. A too-long answer on the current page shows in place, in German too.
The public form says "This answer is too long, please shorten it" (in the form's language) when the server refuses an answer as too long. Every other failure still shows the retry message. Part of BITS-347, goes with the backend PR #293.
payload.<block>), not from the text. No server change needed.Tested: Vitest, lint, vue-tsc. The new test fails without the fix. Not tested: in a browser with #293's code.
🤖 Generated with Claude Code