feat: 新增全局错误透传规则功能
支持管理员配置上游错误如何返回给客户端: - 新增 ErrorPassthroughRule 数据模型和 Ent Schema - 实现规则的 CRUD API(/admin/error-passthrough-rules) - 支持按错误码、关键词匹配,支持 any/all 匹配模式 - 支持按平台过滤(anthropic/openai/gemini/antigravity) - 支持透传或自定义响应状态码和错误消息 - 实现两级缓存(Redis + 本地内存)和多实例同步 - 集成到 gateway_handler 的错误处理流程 - 新增前端管理界面组件 - 新增单元测试覆盖核心匹配逻辑 优化: - 移除 refreshLocalCache 中的冗余排序(数据库已排序) - 后端 Validate() 增加匹配条件非空校验
This commit is contained in:
@@ -3191,6 +3191,80 @@ export default {
|
||||
failedToSave: 'Failed to save settings',
|
||||
failedToTestSmtp: 'SMTP connection test failed',
|
||||
failedToSendTestEmail: 'Failed to send test email'
|
||||
},
|
||||
|
||||
// Error Passthrough Rules
|
||||
errorPassthrough: {
|
||||
title: 'Error Passthrough Rules',
|
||||
description: 'Configure how upstream errors are returned to clients',
|
||||
createRule: 'Create Rule',
|
||||
editRule: 'Edit Rule',
|
||||
deleteRule: 'Delete Rule',
|
||||
noRules: 'No rules configured',
|
||||
createFirstRule: 'Create your first error passthrough rule',
|
||||
allPlatforms: 'All Platforms',
|
||||
passthrough: 'Passthrough',
|
||||
custom: 'Custom',
|
||||
code: 'Code',
|
||||
body: 'Body',
|
||||
|
||||
// Columns
|
||||
columns: {
|
||||
priority: 'Priority',
|
||||
name: 'Name',
|
||||
conditions: 'Conditions',
|
||||
platforms: 'Platforms',
|
||||
behavior: 'Behavior',
|
||||
status: 'Status',
|
||||
actions: 'Actions'
|
||||
},
|
||||
|
||||
// Match Mode
|
||||
matchMode: {
|
||||
any: 'Code OR Keyword',
|
||||
all: 'Code AND Keyword',
|
||||
anyHint: 'Status code matches any error code, OR message contains any keyword',
|
||||
allHint: 'Status code matches any error code, AND message contains any keyword'
|
||||
},
|
||||
|
||||
// Form
|
||||
form: {
|
||||
name: 'Rule Name',
|
||||
namePlaceholder: 'e.g., Context Limit Passthrough',
|
||||
priority: 'Priority',
|
||||
priorityHint: 'Lower values have higher priority',
|
||||
description: 'Description',
|
||||
descriptionPlaceholder: 'Describe the purpose of this rule...',
|
||||
matchConditions: 'Match Conditions',
|
||||
errorCodes: 'Error Codes',
|
||||
errorCodesPlaceholder: '422, 400, 429',
|
||||
errorCodesHint: 'Separate multiple codes with commas',
|
||||
keywords: 'Keywords',
|
||||
keywordsPlaceholder: 'One keyword per line\ncontext limit\nmodel not supported',
|
||||
keywordsHint: 'One keyword per line, case-insensitive',
|
||||
matchMode: 'Match Mode',
|
||||
platforms: 'Platforms',
|
||||
platformsHint: 'Leave empty to apply to all platforms',
|
||||
responseBehavior: 'Response Behavior',
|
||||
passthroughCode: 'Passthrough upstream status code',
|
||||
responseCode: 'Custom status code',
|
||||
passthroughBody: 'Passthrough upstream error message',
|
||||
customMessage: 'Custom error message',
|
||||
customMessagePlaceholder: 'Error message to return to client...',
|
||||
enabled: 'Enable this rule'
|
||||
},
|
||||
|
||||
// Messages
|
||||
nameRequired: 'Please enter rule name',
|
||||
conditionsRequired: 'Please configure at least one error code or keyword',
|
||||
ruleCreated: 'Rule created successfully',
|
||||
ruleUpdated: 'Rule updated successfully',
|
||||
ruleDeleted: 'Rule deleted successfully',
|
||||
deleteConfirm: 'Are you sure you want to delete rule "{name}"?',
|
||||
failedToLoad: 'Failed to load rules',
|
||||
failedToSave: 'Failed to save rule',
|
||||
failedToDelete: 'Failed to delete rule',
|
||||
failedToToggle: 'Failed to toggle status'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user