Skip to content

fix: 自动备份400错误修复及配置切换调度缺陷#18

Merged
lostiv merged 2 commits into
mainfrom
fix/autosync
May 12, 2026
Merged

fix: 自动备份400错误修复及配置切换调度缺陷#18
lostiv merged 2 commits into
mainfrom
fix/autosync

Conversation

@lostiv
Copy link
Copy Markdown
Owner

@lostiv lostiv commented May 12, 2026

  • throwTranslatedError 优先使用 data.error 中的具体错误信息,避免校验失败原因被丢弃
  • checkAndBackup 增加活跃配置变更检测,切换 WebDAV 配置后立即触发新备份
  • 补充 VALIDATION_FAILED 及备份相关错误码映射

- throwTranslatedError 优先使用 data.error 中的具体错误信息,避免校验失败原因被丢弃
- checkAndBackup 增加活跃配置变更检测,切换 WebDAV 配置后立即触发新备份
- 补充 VALIDATION_FAILED 及备份相关错误码映射
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fa8c6e83-2e0b-4ef3-905a-fc456b877447

📥 Commits

Reviewing files that changed from the base of the PR and between dd3c415 and 5366501.

📒 Files selected for processing (1)
  • src/services/backendAdapter.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/backendAdapter.ts

📝 Walkthrough

Summary by CodeRabbit

更新说明

  • Bug Fixes

    • 改进备份功能,在 WebDAV 配置更改时自动重置备份计时,确保下次备份立即执行
    • 优化后端错误处理机制,支持服务器返回的详细错误信息显示
  • New Features

    • 新增五个备份相关操作的多语言错误提示信息

Walkthrough

检测并在 WebDAV 活动配置切换时重置备份计时器;增强后端错误解析以优先使用服务器返回的 error 字段,并新增五个备份相关本地化错误码。

Changes

备份功能和错误处理增强

Layer / File(s) Summary
备份配置变化检测
server/src/services/backupService.ts
checkAndBackup() 中检测 activeConfigId 变化,当 WebDAV 配置切换时重置 lastBackupTime 并更新 lastActiveConfigId,使新配置的备份可立即执行。
后端错误解析与本地化消息
src/services/backendAdapter.ts, src/utils/backendErrors.ts
throwTranslatedError 现在尝试读取响应 JSON 的 error 字段并在存在时直接抛出该消息;ERROR_MESSAGES 新增五个备份相关错误码(VALIDATION_FAILEDUPDATE_BACKUP_SETTINGS_FAILEDFETCH_BACKUP_SETTINGS_FAILEDFETCH_BACKUP_STATUS_FAILEDTRIGGER_BACKUP_FAILED)的中英文翻译。

预估审查工作量

🎯 3 (Moderate) | ⏱️ ~20 分钟

建议标签

bug, frontend, backend

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 标题遵循 Conventional Commits 格式:type(scope): description,使用了 fix 类型,清晰描述了备份错误修复和配置切换问题。
Description check ✅ Passed PR 描述详细说明了三个主要改动,与代码变更相符:错误信息处理优化、配置切换检测和错误码映射。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/autosync
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/autosync

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added bug Something isn't working frontend backend labels May 12, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 43d0ae1 and dd3c415.

📒 Files selected for processing (3)
  • server/src/services/backupService.ts
  • src/services/backendAdapter.ts
  • src/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: 错误码映射补充完整且一致。

新增文案覆盖了校验失败与备份链路常见错误,能提升前端提示质量。

Comment thread src/services/backendAdapter.ts
@lostiv lostiv changed the title Fix/autosync fix: 自动备份400错误修复及配置切换调度缺陷 May 12, 2026
CodeRabbit 审查:data.error 若非字符串会变成 [object Object],增加 typeof 检查,仅当非空字符串时直抛,否则走 code 翻译回退。
@lostiv lostiv merged commit 28aa950 into main May 12, 2026
1 check passed
@lostiv lostiv deleted the fix/autosync branch May 12, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant