Repository navigation
Go: add context, part6 - #17399
Go: add context, part6#17399
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughRequest contexts and explicit database handles now propagate through Langfuse, LLM, user, and admin handler-service-DAO paths. Langfuse verification, persistence, and tests use the supplied context, while related DAO contracts are updated. ChangesLangfuse context-aware persistence
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/service/langfuse_service.go`:
- Line 77: Propagate the request context through both Langfuse verifier calls:
update AuthCheck in internal/service/langfuse_service.go:77-77 and GetProject in
internal/service/langfuse_service.go:110-110 to pass ctx instead of
context.Background(), preserving cancellation and deadline behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b75ea21c-4b80-4ec4-a560-c6c930b2220d
📒 Files selected for processing (6)
internal/dao/langfuse.gointernal/dao/langfuse_test.gointernal/handler/langfuse.gointernal/handler/langfuse_test.gointernal/service/langfuse_service.gointernal/service/langfuse_service_test.go
Signed-off-by: Jin Hai <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
internal/admin/service.go (1)
369-373: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winDo not swallow context cancellation during LLM initialization.
This branch continues on every
GetByFactoryerror, socontext.Canceledandcontext.DeadlineExceededare treated like optional configuration failures. Return context errors immediately; otherwiseCreateUsercan commit after the request has been canceled.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/admin/service.go` around lines 369 - 373, Update the LLM initialization error handling around s.llmDAO.GetByFactory so context.Canceled and context.DeadlineExceeded are returned immediately instead of reaching the continue path. Preserve the warning and optional-configuration behavior for all other errors, ensuring CreateUser propagates cancellation before committing.internal/service/llm.go (1)
61-71: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winApply the request context to these tenant-LLM database operations.
internal/service/llm.go#getMyLLMsand#listLLMscallTenantLLMDAO.ListAllByTenant(tenantID), which uses the global DB without context. Add context-aware variants/signatures for the affected tenant-LLM reads soLLMService.GetMyLLMsandLLMService.ListLLMscan propagate cancellation/deadlines.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/service/llm.go` around lines 61 - 71, The tenant-LLM reads currently use a contextless global database operation; add a context-aware TenantLLMDAO read variant/signature and propagate request contexts through LLMService.GetMyLLMs and LLMService.ListLLMs. Update internal/service/llm.go lines 61-71, 163-195, and 341-349 to pass their contexts, while updating internal/service/user.go line 229 and internal/admin/service.go line 288 to use the new API with their available contexts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@internal/admin/service.go`:
- Around line 369-373: Update the LLM initialization error handling around
s.llmDAO.GetByFactory so context.Canceled and context.DeadlineExceeded are
returned immediately instead of reaching the continue path. Preserve the warning
and optional-configuration behavior for all other errors, ensuring CreateUser
propagates cancellation before committing.
In `@internal/service/llm.go`:
- Around line 61-71: The tenant-LLM reads currently use a contextless global
database operation; add a context-aware TenantLLMDAO read variant/signature and
propagate request contexts through LLMService.GetMyLLMs and LLMService.ListLLMs.
Update internal/service/llm.go lines 61-71, 163-195, and 341-349 to pass their
contexts, while updating internal/service/user.go line 229 and
internal/admin/service.go line 288 to use the new API with their available
contexts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e285bc67-be24-4776-9d70-d37950828d33
📒 Files selected for processing (9)
internal/admin/handler.gointernal/admin/service.gointernal/dao/license.gointernal/dao/llm.gointernal/handler/llm.gointernal/handler/user.gointernal/service/langfuse_service.gointernal/service/llm.gointernal/service/user.go
No description provided.