Skip to content

Commit 1a76b45

Browse files
committed
fix(adapter): 调整 route 字段映射,修复 endpoint 入库异常并增强日志安全性
1 parent 890dbb5 commit 1a76b45

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## 2026-05-21
4+
5+
- 调整 [adapter.js](adapter.js) 的 route 字段映射:
6+
- 聚合写库前,`route`(适配器内部沿用 `endpoint` 字段)改为优先取 `api_key`,其次取 `auth_type`,最后才回退到原始 `endpoint`
7+
- 修复上游队列中 `endpoint``POST /v1/chat/completions` 时被原样入库,导致 route 异常的问题。
8+
- 调试摘要日志中新增 `auth_type`,并对 `api_key` 做脱敏显示,便于排查字段来源且避免泄露敏感值。
9+
310
## 2026-05-10
411

512
-`adapter.js` 增加 Redis 连接错误后的定时无限重连:

adapter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ function normalizeRecord(record) {
121121
if (!record || typeof record !== 'object') return null;
122122

123123
const model = typeof record.model === 'string' && record.model.trim() ? record.model.trim() : 'unknown';
124-
const endpoint = typeof record.endpoint === 'string' && record.endpoint.trim() ? record.endpoint.trim() : 'default';
124+
const apiKey = typeof record.api_key === 'string' && record.api_key.trim() ? record.api_key.trim() : '';
125+
const authType = typeof record.auth_type === 'string' && record.auth_type.trim() ? record.auth_type.trim() : '';
126+
const endpoint = apiKey || authType || (typeof record.endpoint === 'string' && record.endpoint.trim() ? record.endpoint.trim() : 'default');
125127
const source = typeof record.source === 'string' ? record.source : '';
126128
const timestamp = typeof record.timestamp === 'string' && record.timestamp.trim()
127129
? record.timestamp
@@ -184,6 +186,8 @@ function logUsageRecordDiagnostic(record, rawRecord) {
184186
const summary = {
185187
timestamp: record.timestamp,
186188
endpoint: record.endpoint,
189+
auth_type: record.auth_type,
190+
api_key: record.api_key ? '[redacted]' : record.api_key,
187191
provider: record.provider,
188192
model: record.model,
189193
alias: record.alias,

0 commit comments

Comments
 (0)