Repository navigation
feat(ai-gateway): store api_request_log bodies in R2, keep 30 days - #6768
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit switches Files Reviewed (8 files)
Previous Review Summaries (4 snapshots, latest commit d524388)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit d524388)Status: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit only raises the Files Reviewed (2 files)
Previous review (commit aaa5e04)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe single-bucket refactor is mechanically clean and internally consistent ( Overview
Issue Details (click to expand)WARNING
Files Reviewed (11 files)
Fix these issues in Kilo Cloud Previous review (commit 4b5575e)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental commit correctly fixes partial R2 uploads so every object actually written is referenced by its row; the only remaining concern is that R2 bodies still have no deletion path matching the DB retention window. Overview
Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit ca559b3)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (13 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
…orage # Conflicts: # packages/db/src/migrations/meta/0263_snapshot.json # packages/db/src/migrations/meta/_journal.json
Summary
api_request_logrequest and response bodies are now stored in a single R2 bucket instead of in therequest/responsecolumns, so they no longer grow the primary database. DB retention forapi_request_logrows is raised from 7 to 30 days.request_r2_keyandresponse_r2_key. The migration only adds columns. The legacyrequest/responsecolumns stay, and new rows leave themNULL.R2_API_REQUEST_LOG_BUCKET_NAMEunderYYYY-MM-DD/<uuid>/request.jsonand.../response.txt.R2_API_REQUEST_LOG_ACCESS_KEY_IDandR2_API_REQUEST_LOG_SECRET_ACCESS_KEY, in the existingR2_ACCOUNT_IDaccount. The sharedR2_ACCESS_KEY_IDtoken is not used for this bucket.r2/client.tsnow exposes acreateR2Client(credentials)factory, which the sharedr2Clientalso uses.error.r2_upload_error, and the row is still inserted with its metadata. These rows also show up in the errors-only download.<id>_<kind>_load-error.txtentry and the export continues, rather than producing a truncated ZIP.Verification
tsgotypecheck forapps/web,oxlinton changed files,oxfmt.Automated tests are left to CI. New tests use an in-memory fake R2 client and cover:
The cleanup cron test now checks the 30-day cutoff.
No manual end-to-end test: this needs the real bucket and credentials.
Visual Changes
N/A
Reviewer Notes
R2_API_REQUEST_LOG_BUCKET_NAME,R2_API_REQUEST_LOG_ACCESS_KEY_IDandR2_API_REQUEST_LOG_SECRET_ACCESS_KEYviapnpm web:env set <VARIABLE>. Until then, rows are logged withr2_upload_errorand no bodies.R2_ACCOUNT_IDaccount and reachable through the default<account>.r2.cloudflarestorage.comendpoint.request/responsecolumns can be dropped in a follow-up once the retention window has removed all rows that still use them.