forked from zsio/claude-code-hub
-
Notifications
You must be signed in to change notification settings - Fork 113
fix: 修复若干问题 #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fix: 修复若干问题 #62
Conversation
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
- 支持从 Redis/数据库加载每个供应商独立的熔断器配置 - 缓存熔断器配置以减少 Redis 查询并提升性能 - 引入熔断器配置缓存清理功能 - 在服务商管理界面添加熔断器配置项 - 将熔断器状态判断改为异步支持 - 在服务商增删改操作中同步熔断器配置到 Redis - 增加数据库字段以存储熔断器相关配置
- 添加 claude-auth 类型至 Schema、枚举及表单 - 实现 claude-auth 类型的 x-api-key 去除逻辑以避免中转服务冲突 - 更新校验规则以支持 claude-auth 类型 - 在模型选择逻辑中处理 claude-auth 类型
- 支持允许用户清空输入框,在提交时使用默认值 - 更新初始化状态为 undefined,当用户未输入时采用默认值 - 修复表单输入框的 placeholder 适配 - 在提交表单时添加空值处理逻辑以避免错误
- 在健康状态检查中,自动检测并更新过期的熔断器状态 - 打开状态(open)超时后自动转为半开状态(half-open) - 添加日志以记录状态变化 - 优化 Redis 客户端重试日志格式,修复字符串模板问题 - 将 docker-compose 中的 redis 依赖状态从 service_started 更新为 service_healthy 以确保服务健康
- 将 CreateProviderSchema 和 UpdateProviderSchema 的 key 字段的最大长度限制从 255 扩大到 1024 - 支持更长的 API 密钥以满足更复杂的安全需求 - 更新相关校验规则,确保兼容性和一致性
- 实现熔断器告警通知功能,支持 Webhook 推送并防止重复推送(5 分钟内) - 添加每日排行榜通知及成本预警通知,支持定时任务调度 - 引入 Bull 队列管理通知发送及重试逻辑 - 在设置页面新增消息推送管理界面,支持 Webhook 测试及动态配置 - 更新开发环境和生产环境通知任务初始化逻辑,修复相关兼容性问题
- 为每日排行榜和成本预警通知任务引入动态数据生成逻辑 - 在任务执行时动态生成排行榜数据及成本预警数据,去除之前的占位符字段 - 当生成数据为空时跳过任务并新增日志记录以追踪此情况 - 优化 buildDailyLeaderboard 与 buildCostAlert 数据构造逻辑,支持动态输入 - 更新 NotificationJobData 接口,将 data 字段改为可选以支持动态任务
- 移除通知任务队列中的冗余 name 参数,使用 jobId 标识任务以便管理 - 简化每日排行榜、成本预警及熔断器告警消息模板内容,提升信息清晰度 - 调整消息格式,减少冗长说明,优化重要信息展示方式
* fix: 供应商管理列表增加类型筛选和图标显示, close #22 新功能: 1. 增加供应商类型筛选功能 - 支持按 Claude、Claude Auth、Codex、Gemini CLI、OpenAI Compatible 筛选 - 显示当前筛选结果数量 2. 供应商卡片名称增加类型图标和标签 - 类型图标(5 种不同颜色和图标) - 类型标签(文字说明) - 鼠标悬停显示类型描述 实现细节: - 新增 provider-type-utils.tsx:统一管理供应商类型配置 - 新增 provider-type-filter.tsx:类型筛选组件 - 修改 provider-manager.tsx:集成筛选功能和计数显示 - 修改 provider-list-item.tsx:添加类型图标和标签 Close #22 * feat: 添加 @lobehub/icons 依赖并更新供应商类型图标 - 新增 @lobehub/icons 依赖,支持更丰富的图标展示。 - 更新供应商类型配置,使用新的图标组件替代原有图标。 - 为 Anthropic 类型添加专用的橙色包装组件,提升视觉一致性。 影响范围: - 供应商管理界面图标展示更为美观,增强用户体验。 --------- Co-authored-by: Claude Code Bot <[email protected]> Co-authored-by: ding113 <[email protected]>
- 修复 sumUserCostToday 中 SQL JOIN 条件错误(message_request.key 应与 keys.key 关联,而非 keys.id) - 修复日志字符串插值未生效问题(单引号改为反引号) - 移除不必要的类型断言,利用 TypeScript 类型收窄 - 优化 Redis TTL 计算,使用配置时区而非服务器本地时区 - 添加 date-fns-tz 依赖用于时区处理 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
# Conflicts: # VERSION # drizzle/meta/_journal.json # src/lib/circuit-breaker.ts
- Modified `claude-assistant.yml` to reduce pull request event types and limit issue event types to only labeled events. - Updated `claude-ci-autofix.yml` to remove the requirement for associated pull requests, allowing CI fixes on any branch.
- 修复 src/repository/statistics.ts 中的 TypeScript any 类型错误(第 579 行) - 移除 src/app/dashboard/_components/user/key-limit-usage.tsx 中未使用的 err 变量 - 移除 src/app/settings/providers/_components/provider-list-item.tsx 中未使用的导入(ServerCog, AddProviderDialog) - 移除 src/app/usage-doc/page.tsx 中未使用的导入和变量(cn, lang, configDir) - 移除 src/lib/rate-limit/service.ts 中未使用的 now 变量 所有修复均为 ESLint 相关的代码质量改进,不影响功能逻辑。 相关 CI Run: https://github.com/ding113/claude-code-hub/actions/runs/18933737607
- Removed the requirement for the commit message in scenario B to include [skip ci], ensuring it triggers CI again. - Adjusted instructions for auto-fixing CI failures to reflect the new commit message policy. This change aims to streamline the CI process and improve clarity in the workflow documentation.
- Introduced a new environment variable ENABLE_CODEX_INSTRUCTIONS_INJECTION to control the injection of official Codex instructions into requests. - Updated .env.example and CLAUDE.md to document the new feature and its usage scenarios. - Modified request-sanitizer.ts to implement the logic for conditionally replacing instructions based on the new feature flag. This enhancement allows for better compatibility with certain Codex providers that require official instructions.
**Bug 描述:**
- cleanup-queue.ts 在模块加载时立即创建 Bull Queue 实例
- 配置 enableOfflineQueue: false 导致 Redis 未连接时抛出错误
- Promise rejection 未被捕获,导致 unhandledRejection 错误
**问题日志:**
```
{"level":"error","action":"schedule_auto_cleanup_error","error":"Stream isn't writeable and enableOfflineQueue options is false"}
[Error: Stream isn't writeable and enableOfflineQueue options is false]
⨯ unhandledRejection: [Er
```
**修复方案:**
- 将 cleanupQueue 从导出常量改为私有变量
- 添加 getCleanupQueue() 延迟初始化函数
- 更新所有使用 cleanupQueue 的地方调用 getter
- 参考 notification-queue.ts 的正确模式
**测试结果:**
✅ TypeScript 类型检查通过
✅ 生产构建成功
✅ Docker 容器启动正常
✅ 清理队列初始化成功(cleanup_queue_initialized)
✅ 自动清理任务调度成功(auto_cleanup_scheduled)
✅ 无 unhandledRejection 错误
✅ 无 "Stream isn't writeable" 错误
**关联 PR:** #29
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: 修复用户分组过滤功能 - 补全 providerGroup 字段查询 (#31) 修复问题: validateApiKeyAndGetUser 函数在查询用户信息时遗漏了 providerGroup 字段,导致 session.authState.user.providerGroup 始终为 undefined,供应商选择器中的用户分组过滤逻辑无法生效。 修改内容: - 在 SELECT 查询中添加 userProviderGroup: users.providerGroup - 在构建 User 对象时传递 providerGroup: row.userProviderGroup 影响范围: - 恢复用户分组过滤功能,使设置了 providerGroup 的用户请求能够正确过滤到对应 groupTag 的供应商 - 向后兼容,未设置 providerGroup 的用户行为不变 - 无需数据库迁移或环境变更" Co-authored-by: GuShenghua <[email protected]> * chore: sync VERSION file with release v0.2.13 [skip ci] * feat: 价格表页面增加分页功能,close #35 - 添加分页接口 PaginationParams 和 PaginatedResult - 新增 findAllLatestPricesPaginated 分页查询方法 - 新增 getModelPricesPaginated action 函数 - 新增 /api/prices API 端点支持分页查询 - 重构 PriceList 组件支持分页、页面大小选择、搜索 - 修改价格表页面支持分页参数和降级处理 - 支持URL参数同步分页状态 - 优化性能,避免一次性加载大量数据 * fix: 修复价格表分页功能的审查意见 主要改进: - 添加 /api/prices 端点权限检查,确保只有管理员可访问 - 实现 SQL 层面的搜索过滤,提升大数据量场景下的性能 - 添加搜索防抖机制(500ms),优化用户体验 - 移除客户端过滤逻辑,统一使用后端搜索 - 优化 useEffect 依赖,避免不必要的 API 请求 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: gsh <[email protected]> Co-authored-by: GuShenghua <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: GitHub Assistant <[email protected]> Co-authored-by: ding113 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Ding <[email protected]>
- Added a new navigation item for the API documentation in the settings menu. - Updated package.json and pnpm-lock.yaml to include new dependencies: @hono/swagger-ui, @hono/zod-openapi, and @scalar/hono-api-reference.
- Add eslint-disable comments for necessary 'any' types in action-adapter-openapi.ts - Remove unused webhookUrl parameter from sendCircuitBreakerAlert function - Remove unused imports (systemConfigActions, KeyFormSchema) from actions route - Fix React hooks exhaustive-deps warning by wrapping loadSettings with useCallback - Remove unused settings state variable in notifications page These changes fix all ESLint errors that were blocking the Docker build in CI.
- Added automated API documentation generation using OpenAPI 3.1.0 with Swagger and Scalar UI, supporting 39 REST API endpoints. - Implemented pagination for the price list, optimizing performance for large datasets with SQL-level enhancements and search debounce. - Updated CLAUDE.md and README.md to reflect new features and usage instructions for API documentation and pagination. These changes improve usability and performance for managing API interactions and large data queries.
- 将优先级说明从 "(0最高)" 改为 "(数值越小优先级越高,0为最高)" - 消除用户对优先级排序规则的理解歧义 - 明确说明数值越小优先级越高,0为最高优先级 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Implements comprehensive proxy configuration for providers to improve connectivity from restricted networks (e.g., mainland China accessing overseas APIs). ## New Features ### Database Schema - Added `proxy_url` field (varchar 512) to providers table - Added `proxy_fallback_to_direct` boolean field with default false - Created migration file 0014_overconfident_mongu.sql ### Core Proxy Logic - Created `src/lib/proxy-agent.ts` with auto-detection of proxy protocols - HTTP/HTTPS: uses undici ProxyAgent - SOCKS4/SOCKS5: uses SocksProxyAgent - Includes proxy URL validation and password masking for logs - Integrated proxy support into request forwarding layer (forwarder.ts) - Applied dispatcher to fetch requests - Implemented fallback-to-direct logic on proxy failures - Added detailed proxy error logging ### Connection Testing - Created `testProviderProxy` Server Action - Uses HEAD request (no quota consumption) - 5-second timeout - Returns detailed results (status code, response time, proxy usage, errors) - Created ProxyTestButton component with real-time status display - Shows testing state (in-progress, success, failure) - Displays detailed results (status code, response time, connection method, error type) - Toast notifications integration ### UI Integration - Extended provider form with "Proxy Configuration" section - Proxy URL input with protocol examples - Fallback strategy switch - Test connection button - State management and form submission - Updated Server Actions to handle proxy fields (addProvider/editProvider/getProviders) ### Type Safety & Validation - Updated TypeScript interfaces (Provider, ProviderDisplay, CreateProviderData, UpdateProviderData) - Added Zod validation schemas with length limits - All type checks passing ### Documentation - Added "Proxy Support" section to CLAUDE.md - Configuration guide - Technical implementation details - Usage scenarios - Added "Proxy Connection Failure" troubleshooting section ## Dependencies - Added `[email protected]` - Added `[email protected]` (dev dependency for types) ## Technical Details - Auto-protocol detection based on URL scheme - Per-provider configuration granularity - Optional fallback to direct connection on proxy failures - Security: automatic password masking in logs - Supports authenticated proxies (username:password@host:port) Closes #41 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This migration file was a duplicate entry created during PR #42 merge. It was never registered in _journal.json and the fields it added (allow_view_provider_info, non_admin_currency_display) were not included in schema.ts or used in the codebase. The official 0013 migration is 0013_outgoing_justin_hammer.sql which creates the notification_settings table. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Resolved conflicts: - VERSION: Updated to 0.2.22 - public/seed/litellm-prices.json: Used main's version (more up-to-date) - drizzle/meta/_journal.json: Kept dev's migration 0014 - src/app/v1/_lib/proxy/forwarder.ts: Merged client abort detection with proxy error handling - Removed duplicate migration file 0013_optimal_darkhawk.sql Changes from main: - REST API support and notification system (PR #42) - Updated LiteLLM price data - Version bump to 0.2.22 Changes from dev: - Provider-level proxy support (HTTP/HTTPS/SOCKS4/SOCKS5) - API documentation enhancements - Price table pagination - Migration 0014 for proxy fields All type checks passed ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
针对 claude bot 在 PR #49 中提出的 4 个改进建议进行修复: 1. proxy-agent.ts - 修复 fallbackToDirect 默认值处理 - 使用空值合并运算符 (??) 确保默认值为 false - 避免 undefined/null 导致降级逻辑失效 2. env.schema.ts - 提取布尔值转换逻辑为公共函数 - 减少代码重复,提高可维护性 - 5 处重复逻辑统一使用 booleanTransform 函数 3. forwarder.ts - 修复代理降级逻辑的配置残留问题 - 创建新的配置对象而非修改原对象 - 避免代理配置残留导致的潜在问题 4. proxy-test-button.tsx - 改进超时错误提示 - 提供详细的故障排查步骤 - 延长 toast 显示时间到 5 秒 所有修复已通过 typecheck 和 format 验证。 Ref: #49 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
* fix: 修复 Session 数据越权访问漏洞, close #51 ## 问题描述 普通用户(非管理员令牌)登录 Web UI 后,可以通过"仪表盘" → "活跃 Session" 查看到其他用户 5 分钟内的请求内容和响应内容,造成严重的数据泄露。 ## 安全影响 - **数据泄露风险**: 用户可以查看其他用户的敏感请求和响应 - **隐私侵犯**: 违反用户数据隔离原则 - **合规风险**: 可能违反数据保护法规(如 GDPR) ## 修复方案 在所有 Session 相关 API 中添加用户权限检查: 1. **getActiveSessions()** - 列表过滤 - 管理员:可查看所有用户的 Session - 普通用户:只能查看自己的 Session 2. **getAllSessions()** - 列表过滤 - 同上,支持活跃和非活跃 Session 3. **getSessionDetails()** - 详情访问控制 - 检查 Session 所有权 - 非所有者尝试访问时记录安全日志并拒绝 4. **getSessionMessages()** - 消息访问控制 - 检查 Session 所有权 - 记录越权访问尝试 5. **getSessionResponse()** - 响应体访问控制 - 检查 Session 所有权 - 记录越权访问尝试 ## 技术实现 - 使用 `getSession()` 获取当前登录用户 - 通过 `aggregateSessionStats()` 查询 Session 的 userId - 比对 `sessionStats.userId` 与 `currentUserId` - 所有越权访问尝试都会记录安全日志 ## 测试建议 1. 创建两个普通用户(user1, user2) 2. user1 发起 API 请求产生 Session 3. user2 登录 Web UI 尝试查看 user1 的 Session 4. 预期结果:user2 只能看到自己的 Session,无法看到 user1 的 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Code Bot <[email protected]> Co-authored-by: Claude <[email protected]>
|
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.
No description provided.