Skip to content

Say when an answer is too long to store - #294

Merged
PhilReinking merged 4 commits into
mainfrom
fix/bits-347-too-long-message
Oct 17, 2026
Merged

PhilReinking merged 4 commits into
mainfrom
fix/bits-347-too-long-message

Conversation

@PhilReinking

Copy link
Copy Markdown
Contributor

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.

  • The case is picked from the 422's error field (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

PhilReinking and others added 2 commits October 17, 2026 12:47
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@PhilReinking PhilReinking left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread resources/js/stores/conversation.ts Outdated
Comment on lines +573 to +577
this.submitTooLong =
response?.status === 422 &&
Object.keys(response.data?.errors ?? {}).some(
(field) => field.startsWith("payload."),
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PhilReinking left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +587 to +594
if (
onPath !== -1 &&
this.tooLongBlock &&
this.findBlockIndex(this.tooLongBlock) !== -1
) {
this.current = this.tooLongBlock;
this.path = this.path.slice(0, onPath);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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 PhilReinking left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@PhilReinking
PhilReinking merged commit 11c0e26 into main Oct 17, 2026
6 checks passed
@PhilReinking
PhilReinking deleted the fix/bits-347-too-long-message branch October 17, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant