fix: 自动备份400错误修复及配置切换调度缺陷#18
Merged
Merged
Conversation
Owner
lostiv
commented
May 12, 2026
- throwTranslatedError 优先使用 data.error 中的具体错误信息,避免校验失败原因被丢弃
- checkAndBackup 增加活跃配置变更检测,切换 WebDAV 配置后立即触发新备份
- 补充 VALIDATION_FAILED 及备份相关错误码映射
- throwTranslatedError 优先使用 data.error 中的具体错误信息,避免校验失败原因被丢弃 - checkAndBackup 增加活跃配置变更检测,切换 WebDAV 配置后立即触发新备份 - 补充 VALIDATION_FAILED 及备份相关错误码映射
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/backendAdapter.ts`:
- Around line 81-89: The current handler reads res.json() into data and directly
assigns data.error to serverError then throws it, which can stringify objects to
“[object Object]”; update the logic in the backendAdapter response handling
(around res.json(), code, serverError) to type-guard data.error: if typeof
data.error === 'string' && data.error.trim() !== '' then throw new
Error(data.error), otherwise do not throw the raw value and instead fall back to
the existing code-based translation/fallback path (use the code variable to
produce a user-friendly message); ensure you do not expose non-string error
objects directly to the UI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 54a83ee2-cb0b-497b-940f-ccaeb9a4490d
📒 Files selected for processing (3)
server/src/services/backupService.tssrc/services/backendAdapter.tssrc/utils/backendErrors.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
src/services/**
⚙️ CodeRabbit configuration file
src/services/**: API 服务层。审查时请关注: 1. fetch 请求的超时处理(AbortController) 2. 错误处理和用户友好的错误信息翻译 3. API 密钥/Token 的传输安全性 4. 请求重试和降级策略 5. WebDAV/后端代理的 CORS 处理
Files:
src/services/backendAdapter.ts
server/src/services/**
⚙️ CodeRabbit configuration file
server/src/services/**: 后端服务层。审查时请关注: 1. 加密解密逻辑的正确性(AES-256-GCM) 2. 密钥管理和随机性 3. 错误处理不泄露敏感信息
Files:
server/src/services/backupService.ts
🔇 Additional comments (2)
server/src/services/backupService.ts (1)
356-360: 配置切换后立即触发备份的策略实现正确。这段逻辑能确保活跃配置变更后不受旧间隔限制,符合自动备份预期。
src/utils/backendErrors.ts (1)
54-58: 错误码映射补充完整且一致。新增文案覆盖了校验失败与备份链路常见错误,能提升前端提示质量。
CodeRabbit 审查:data.error 若非字符串会变成 [object Object],增加 typeof 检查,仅当非空字符串时直抛,否则走 code 翻译回退。
This was referenced May 12, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.