fix(brand-questions): surface seed topic min length as actionable error
Reject AI seed topics shorter than 2 characters on both client and server with a dedicated invalid_seed_topic error code, and render an inline hint listing the offending terms so users know exactly what to fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -140,6 +140,8 @@ export function isHandledAuthError(error: unknown): boolean {
|
||||
}
|
||||
|
||||
const TIMEOUT_MESSAGE_PATTERN = /^timeout of \d+ms exceeded$/i
|
||||
const VALIDATION_MIN_SEED_TOPIC_PATTERN =
|
||||
/QuestionDistillRequest\.SeedTopic|seed_topic.*min|SeedTopic.*min/i
|
||||
|
||||
function translateRawErrorMessage(raw: string): string | null {
|
||||
const mapped = errorMessageMap[raw]
|
||||
@@ -158,6 +160,13 @@ export function formatError(error: unknown): string {
|
||||
}
|
||||
|
||||
if (error instanceof ApiClientError) {
|
||||
if (
|
||||
error.message === 'invalid_seed_topic' ||
|
||||
(error.message === 'invalid_params' &&
|
||||
VALIDATION_MIN_SEED_TOPIC_PATTERN.test(error.detail ?? ''))
|
||||
) {
|
||||
return '用户搜索词太短,请输入至少 2 个字的搜索词'
|
||||
}
|
||||
const translated = translateRawErrorMessage(error.message)
|
||||
const message = translated ?? error.message.replaceAll('_', ' ')
|
||||
if (isAiPointsInsufficient(error)) {
|
||||
|
||||
Reference in New Issue
Block a user