fix(message): 回调验证日志不再输出 token

消息回调验证入口 GET /api/v1/message/ 以 INFO 级别记录请求参数,其中的
token 就是 verify_apitoken 校验用的 API_TOKEN。日志经常被直接贴出来排查
问题,因此去掉这个字段,其余排查用参数保持不变。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LIN student
2026-10-04 19:01:22 +08:00
parent c8869d4b89
commit 4416e278aa
2 changed files with 16 additions and 1 deletions

View File

@@ -337,7 +337,7 @@ def incoming_verify(
微信/VoceChat等验证响应
"""
logger.info(
f"收到验证请求: token={token}, echostr={echostr}, "
f"收到验证请求: echostr={echostr}, "
f"msg_signature={msg_signature}, timestamp={timestamp}, nonce={nonce}"
)
if echostr and msg_signature and timestamp and nonce:

View File

@@ -2,6 +2,7 @@ import asyncio
import json
from unittest.mock import Mock
from app.api.endpoints import message as message_endpoint
from app.api.endpoints.message import clear_notification_message, get_notification_message
from app.api.endpoints.system import get_message
from app.chain.base import ChainBase
@@ -212,6 +213,20 @@ def test_sse_endpoint_flushes_backlog_in_one_tick() -> None:
assert helper.get() is None
def test_incoming_verify_log_omits_token(monkeypatch) -> None:
"""
回调验证日志只记录排查所需的参数,不输出 token。
"""
logged: list[str] = []
monkeypatch.setattr(message_endpoint.logger, "info", lambda msg, *args, **kwargs: logged.append(str(msg)))
result = message_endpoint.incoming_verify(token="callback-token-value", source="vocechat")
assert result == {"status": "OK"}
assert logged
assert all("callback-token-value" not in line for line in logged)
def test_agent_helper_message_does_not_enter_sse_queue() -> None:
"""
智能体消息不进入前端 SSE 队列。