Repository navigation
Go: add context, part12 - #17435
Go: add context, part12#17435
Conversation
Signed-off-by: Jin Hai <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTenant DAO operations, service methods, handlers, and ingestion dispatchers now propagate request contexts and explicit GORM database handles. Related tests and resolver mocks were updated for the new call signatures. ChangesContext propagation and tenant access
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/service/tenant.go (1)
835-840: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winReturn the tenant update error.
A failed update is currently reported as success, leaving the default model unchanged while callers proceed as though it was saved.
Proposed fix
err = s.tenantDAO.Update(ctx, dao.DB, ownedTenant.TenantID, map[string]interface{}{ modelTypeID: defaultModel, tenantModelTypeID: tenantModelID, }) - return nil + return err🤖 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/tenant.go` around lines 835 - 840, Return the error from the tenantDAO.Update call in the surrounding tenant service method instead of unconditionally returning nil. Preserve the existing update arguments and successful nil return, allowing callers to receive failures when the default model update does not persist.
🧹 Nitpick comments (2)
internal/ingestion/component/parser.go (1)
488-492: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove Python migration-history references from Go comments.
Describe the current Go behavior without
Mirrors Pythonpaths or legacy implementation notes.
internal/ingestion/component/parser.go#L488-L492: retain the Markdown vision behavior description, but remove the Python_Markdownreference.internal/ingestion/component/pdf_vision_dispatch.go#L102-L103: document the MinerU request/response behavior without referencingmineru_parser.py.As per coding guidelines, “Keep Go package comments and doc comments aligned with the current runtime path rather than migration history.”
🤖 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/ingestion/component/parser.go` around lines 488 - 492, Remove the Python migration reference from the Markdown vision comment above maybeDispatchMarkdownVision in internal/ingestion/component/parser.go lines 488-492 while retaining its description of enriching referenced images with LLM-generated descriptions. Update the MinerU comment in internal/ingestion/component/pdf_vision_dispatch.go lines 102-103 to describe the current request/response behavior without mentioning mineru_parser.py.Source: Coding guidelines
internal/ingestion/component/parser_dispatch_test.go (1)
429-432: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the injected context and database are forwarded.
The updated stubs accept but ignore
ctxanddb, while each test invokesParserComponent.Invokewithnil. Pass sentinel values and assert identity in the PDF vision and MinerU resolvers so a regression to a global or unrelated DB cannot pass unnoticed.
internal/ingestion/component/parser_dispatch_test.go#L429-L432: assert the PDF vision resolver receives the supplied context and database.internal/ingestion/component/parser_dispatch_test.go#L509-L512: assert the empty-page PDF vision path receives the supplied context and database.internal/ingestion/component/parser_dispatch_test.go#L567-L568: assert the MinerU resolver receives the supplied context and database.🤖 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/ingestion/component/parser_dispatch_test.go` around lines 429 - 432, Update the PDF vision resolver stubs at internal/ingestion/component/parser_dispatch_test.go:429-432 and :509-512, and the MinerU resolver stub at :567-568, to assert that the received context and database are identical to supplied sentinel values. Replace nil arguments in the corresponding ParserComponent.Invoke calls with those sentinels, while preserving the existing tenant/model assertions and test behavior.
🤖 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/handler/mindmap.go`:
- Line 77: Update the timeout context initialization near the fallback lookup in
the handler so it derives from the incoming request context rather than
context.Background(). Ensure GetDefaultModelName receives this derived context,
preserving request cancellation and deadlines.
---
Outside diff comments:
In `@internal/service/tenant.go`:
- Around line 835-840: Return the error from the tenantDAO.Update call in the
surrounding tenant service method instead of unconditionally returning nil.
Preserve the existing update arguments and successful nil return, allowing
callers to receive failures when the default model update does not persist.
---
Nitpick comments:
In `@internal/ingestion/component/parser_dispatch_test.go`:
- Around line 429-432: Update the PDF vision resolver stubs at
internal/ingestion/component/parser_dispatch_test.go:429-432 and :509-512, and
the MinerU resolver stub at :567-568, to assert that the received context and
database are identical to supplied sentinel values. Replace nil arguments in the
corresponding ParserComponent.Invoke calls with those sentinels, while
preserving the existing tenant/model assertions and test behavior.
In `@internal/ingestion/component/parser.go`:
- Around line 488-492: Remove the Python migration reference from the Markdown
vision comment above maybeDispatchMarkdownVision in
internal/ingestion/component/parser.go lines 488-492 while retaining its
description of enriching referenced images with LLM-generated descriptions.
Update the MinerU comment in internal/ingestion/component/pdf_vision_dispatch.go
lines 102-103 to describe the current request/response behavior without
mentioning mineru_parser.py.
🪄 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: 116f0b55-6a17-4902-b43d-70946bd84e11
📒 Files selected for processing (36)
internal/dao/tenant.gointernal/dao/tenant_test.gointernal/handler/dataset.gointernal/handler/document.gointernal/handler/mindmap.gointernal/handler/providers.gointernal/handler/searchbot.gointernal/handler/tenant.gointernal/ingestion/component/dispatch_model.gointernal/ingestion/component/docx_vision_dispatch.gointernal/ingestion/component/docx_vision_dispatch_test.gointernal/ingestion/component/markdown_vision_dispatch.gointernal/ingestion/component/media_dispatch.gointernal/ingestion/component/media_dispatch_test.gointernal/ingestion/component/parser.gointernal/ingestion/component/parser_dispatch_pdf_vision_cgo_test.gointernal/ingestion/component/parser_dispatch_test.gointernal/ingestion/component/pdf_vision_dispatch.gointernal/ingestion/task/task_context.gointernal/service/chat.gointernal/service/chat_session.gointernal/service/chunk/chunk.gointernal/service/dataset/crud.gointernal/service/dataset/permission.gointernal/service/document/file2document.gointernal/service/file_permission.gointernal/service/mcp.gointernal/service/model_service.gointernal/service/oauth_login.gointernal/service/related_question.gointernal/service/search.gointernal/service/skill_space.gointernal/service/team_permission.gointernal/service/tenant.gointernal/service/tenant_test.gointernal/service/user.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 (1)
internal/handler/mindmap.go (1)
64-66: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winBound the mindmap request context.
ChatStreamnow forwardsctxinto the model driver, and the fallback lookup/stream also usesctx, so an unbounded request can hang indefinitely insideChatStreamlyWithSenderor database lookups. Usecontext.WithTimeout(ctx, 10*time.Minute)for the stream and derived fallback lookup, while still honoring the original request cancellation.🤖 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/handler/mindmap.go` around lines 64 - 66, Update the mindmap handler around ChatStream and ChatStreamlyWithSender to derive a context with a 10-minute timeout from the incoming ctx, and use that derived context for the model stream and fallback database lookup. Preserve propagation of the original request cancellation and ensure the timeout context is properly released.
🤖 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/handler/mindmap.go`:
- Around line 64-66: Update the mindmap handler around ChatStream and
ChatStreamlyWithSender to derive a context with a 10-minute timeout from the
incoming ctx, and use that derived context for the model stream and fallback
database lookup. Preserve propagation of the original request cancellation and
ensure the timeout context is properly released.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ccdfb4d-cfe9-43be-ad28-a89f8241f236
📒 Files selected for processing (2)
internal/handler/mindmap.gointernal/service/tenant.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/service/tenant.go
Signed-off-by: Jin Hai <[email protected]>
No description provided.