fix(integrations): accept a github first sync that crosses a month's end
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 57/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Read collectBilling and monthsToSync in src/lib/adapters/github/billing.ts, then follow the existing boundary test in src/lib/adapters/github/index.test.ts. First decide which month-boundary behavior to use and present the options as a table on the issue before coding. Add the reproduction test and verify the first sync stores a valid batch without an invalid_response retry.
由索引模型根据 Issue 内容生成。
描述
Context
Found while fixing #732. A GitHub account's first sync that starts before 00:00 UTC on a month's last day and reads that month's billing summary after 00:00 fails validation, and the job retries it.
How it happens, on main and on the #732 branch alike:
collectBilling(src/lib/adapters/github/billing.ts) picks the months to read from the clock at the start of the sync (monthsToSync(now)). A sync that starts at 2026-10-31T23:59:59Z reads October only, as the current month.- If the summary is read at 2026-11-01T00:00:01Z, October's month to date has a
retrievedAtafter its period ended (the period ends at 2026-11-01T00:00Z). collectPastDaysstates the daily amounts up to 2026-10-31 against that reading, andvalidateAdapterMetrics(pastDayIssuesinsrc/lib/adapters/metrics.ts) rejects every one: "a daily amount's live reading must be a running total: a period from the first day of a UTC month, still open when it was read".- The whole batch fails (
InvalidResponseErrorinsrc/lib/jobs/sync-connection.ts, around line 222).invalid_responseis not a permanent code, so the job retries after backoff, and the retry, after 00:00, reads both months and succeeds.
Reproduction: in src/lib/adapters/github/index.test.ts, copy the test "decides the past days against the day the month to date was read when the sync crosses 00:00 UTC (boundary: midnight)" and move the clock to 2026-11-01T00:00:01Z when the summary route is called instead of when /usage is. checkSyncResult then returns one issue per daily amount, all with the message above. Run on the #732 branch at 0d2255ac; not committed.
Impact: low. Only a first sync that reads its summary in the seconds just past midnight on a month's last day hits it. It records invalid_response on the connection, then succeeds on the retry, and no data is lost. A later sync is not affected: it states no daily amounts.
Plan
- Decide how a first sync should treat a month it reads after the month ended. For example: decide "current" per reading from its
retrievedAtand read the new month too, or keep the clock at the start of the sync for every read. Present the options as a table on this issue before writing code. - Add the reproduction above as a unit test.
Acceptance criteria
- A first sync that reads its month's summary just after 00:00 UTC on the month's last day stores a valid batch, without an
invalid_responsefailure and retry. - Unit test for that case in
src/lib/adapters/github/index.test.ts. - Playwright: none needed, because the change is in a sync's stored rows.
Files and areas
src/lib/adapters/github/billing.ts (collectBilling, monthsToSync), src/lib/adapters/github/index.test.ts, src/lib/adapters/metrics.ts (read only). Non-goals: the 3 day grace window, later syncs, other providers.
Verification
npx vitest run src/lib/adapters/github src/lib/adapters/metrics.test.tsnpm run typecheck,npm run lint,npm test
Branch: <issue-number>-<slug>
Closes with a Closes #<issue-number> footer on the commit or pull request.
Model: anthropic/claude-opus-5-5 | Reasoning effort: max
- 主要语言
- TypeScript
- 星标
- 13
- 派生
- 2
- 平均合并
- 5 小时 20 分钟
- 30 天内合并 PR
- 287
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
eddiejaoude/StackDash 的其他 Issue
-
area: integrations documentation priority: P2 size: XS
难度 2/5 1-3 小时 新手友好度 78/100
eddiejaoude/StackDash#798 ·
维护者通常 1 天内回复
-
area: ops documentation priority: P3 size: XS
难度 2/5 1-3 小时 新手友好度 82/100
eddiejaoude/StackDash#796 ·
维护者通常 1 天内回复
-
area: docs documentation impact: low priority: P3 size: XS
难度 2/5 1-3 小时 新手友好度 76/100
eddiejaoude/StackDash#790 ·
维护者通常 1 天内回复
-
area: ops bug impact: low priority: P3 size: XS
难度 2/5 1-3 小时 新手友好度 76/100
eddiejaoude/StackDash#785 ·
维护者通常 1 天内回复
-
area: connections enhancement impact: low priority: P3 size: XS
难度 2/5 1-3 小时 新手友好度 86/100
eddiejaoude/StackDash#768 ·
维护者通常 1 天内回复
查看 eddiejaoude/StackDash 的全部 Issue
相似的 Issue
-
bot:ai-assisted component:midnight-js status:untriaged
难度 2/5 1-3 小时 新手友好度 72/100
midnightntwrk/midnight-js#1790 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
area:vscode bug has repro platform:macos platform:vscode regression
难度 2/5 1-3 小时 新手友好度 70/100
anthropics/claude-code#113502 ·
-
check:passed streams:add
难度 1/5 1 小时以内 新手友好度 77/100
维护者通常 1 天内回复
-
effort/l priority/p1 risk/high triage/core
难度 2/5 1-3 小时 新手友好度 76/100
iflytek/skillhub#1188 · 1 条评论 ·
维护者通常 1 天内回复