fix: address code review - sanitize error output, fix timezone calc, narrow git add scope [skip ci]

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/bc1b54c6-5276-4d00-8ea5-5e8c3c2bef38
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 07:15:55 +00:00
parent 0d842e52df
commit 368a7f139f
4 changed files with 10 additions and 7 deletions

View File

@ -68,6 +68,7 @@ jobs:
run: |
git config user.name "zhuyuan-bot"
git config user.email "zhuyuan@guanghulab.com"
git add config/gdrive-tokens.json grid-db/logs/
git add config/gdrive-tokens.json
git add -f grid-db/logs/token-alert.json 2>/dev/null || true
git diff --cached --quiet || git commit -m "auto: Token health check $(date -u +%Y-%m-%dT%H:%M:%SZ) [skip ci]"
git push

View File

@ -58,7 +58,8 @@ jobs:
run: |
git config user.name "zhuyuan-bot"
git config user.email "zhuyuan@guanghulab.com"
git add config/gdrive-tokens.json grid-db/logs/
git add config/gdrive-tokens.json
git add -f grid-db/logs/token-alert.json 2>/dev/null || true
git diff --cached --quiet || git commit -m "auto: Token renewal $(date -u +%Y-%m-%dT%H:%M:%SZ) [skip ci]"
git push

View File

@ -17,8 +17,9 @@
function isInHibernation() {
const now = new Date();
// 转换为北京时间
const cst = new Date(now.toLocaleString('en-US', { timeZone: 'Asia/Shanghai' }));
// 转换为北京时间UTC+8使用 UTC 偏移计算避免 locale 差异
const utcMs = now.getTime() + now.getTimezoneOffset() * 60 * 1000;
const cst = new Date(utcMs + 8 * 60 * 60 * 1000);
const day = cst.getDay(); // 0=周日, 6=周六
const hour = cst.getHours();
const minute = cst.getMinutes();

View File

@ -104,8 +104,8 @@ async function main() {
console.log(` ✅ 刷新成功!新过期时间: ${token.expires_at}`);
results.renewed.push(token.user_id);
} else {
// Google 有时不返回新的 refresh_token
console.log(` ⚠️ Google 未返回新 refresh_tokenToken 可能仍然有效但无法续期`);
// Google 有时不返回新的 refresh_tokenaccess_type 非 offline 或非首次授权时常见)
console.log(` ⚠️ Google 未返回新 refresh_token需人类重新授权access_type=offline + prompt=consent`);
token.status = 'expiring';
registry.renew_log.push({
user_id: token.user_id,
@ -202,7 +202,7 @@ async function refreshOAuth2Token(refreshToken) {
resolve(json);
}
} catch (e) {
reject(new Error(`Invalid response from Google: ${data.substring(0, 200)}`));
reject(new Error('Invalid JSON response from Google OAuth2 endpoint'));
}
});
});