Repository navigation
Go: add context, part10 - #17417
Go: add context, part10#17417
Conversation
Signed-off-by: Jin Hai <[email protected]>
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughSystem settings DAO, service, and handler APIs now propagate request contexts and explicit database handles. Sandbox provider loading uses the same context/database-aware seam, while execution accepts a new structured-result metadata key with backward compatibility. ChangesContext and database propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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: 2
🤖 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/agent/sandbox/manager_test.go`:
- Line 402: Update fakeSettingsReader.GetByName to match the SettingsReader
interface by adding the *gorm.DB parameter in the correct position, and import
GORM in the test file. Preserve the existing return behavior so
Load从SettingsWithReader tests compile and continue using the fake.
In `@internal/dao/system_settings.go`:
- Around line 37-39: Update SystemSettingsDAO.GetAll to query through
db.WithContext(ctx) instead of the global DB. Update Transaction to invoke the
transaction on db.WithContext(ctx), and ensure direct transaction helpers use a
context-bearing tx so cancellation and deadlines propagate through all queries.
🪄 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: 067a0c48-c4ae-42e4-b4c6-c0c44c1a7109
📒 Files selected for processing (10)
internal/admin/handler.gointernal/admin/service.gointernal/agent/sandbox/manager.gointernal/agent/sandbox/manager_client.gointernal/agent/sandbox/manager_test.gointernal/agent/tool/code_exec.gointernal/agent/tool/code_exec_client.gointernal/dao/system_settings.gointernal/handler/system.gointernal/service/system.go
Signed-off-by: Jin Hai <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/agent/sandbox/manager_test.go (1)
405-405: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the new context/DB propagation.
The fake discards both new parameters, so these tests cannot detect a regression that passes the wrong context or DB. Capture them and assert the caller-provided sentinel values in one load and reload test.
As per coding guidelines, “Preserve valid behavior with focused tests.”
🤖 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/agent/sandbox/manager_test.go` at line 405, Update fakeSettingsReader.GetByName to capture the provided context and *gorm.DB instead of discarding them, then add assertions in one load test and one reload test that both match caller-provided sentinel values. Keep the existing settings behavior intact while verifying propagation through the relevant load and reload paths.Source: Coding guidelines
🤖 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/agent/sandbox/manager.go`:
- Around line 168-169: The runtime LoadFromSettings entry point currently
hard-codes dao.DB, preventing caller-owned database or transaction use. Update
ProviderManager.LoadFromSettings to accept a *gorm.DB parameter and pass it to
LoadFromSettingsWithReader; update the owning ManagerClient.ExecuteCode call
path to provide its active database handle.
---
Nitpick comments:
In `@internal/agent/sandbox/manager_test.go`:
- Line 405: Update fakeSettingsReader.GetByName to capture the provided context
and *gorm.DB instead of discarding them, then add assertions in one load test
and one reload test that both match caller-provided sentinel values. Keep the
existing settings behavior intact while verifying propagation through the
relevant load and reload paths.
🪄 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: 8c726378-9a73-474e-b45e-a6a218c44fbd
📒 Files selected for processing (6)
internal/agent/sandbox/aliyun.gointernal/agent/sandbox/manager.gointernal/agent/sandbox/manager_client.gointernal/agent/sandbox/manager_test.gointernal/agent/sandbox/self_managed.gointernal/dao/system_settings.go
| func (m *ProviderManager) LoadFromSettings(ctx context.Context) error { | ||
| return m.LoadFromSettingsWithReader(ctx, dao.NewSystemSettingsDAO()) | ||
| return m.LoadFromSettingsWithReader(ctx, dao.DB, dao.NewSystemSettingsDAO()) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Keep the DB handle injectable on the runtime entry point.
LoadFromSettings hard-codes dao.DB, so the normal ManagerClient.ExecuteCode path cannot use a caller-owned database or transaction; only the test-oriented WithReader path can. Accept db *gorm.DB here and forward it from the owning caller instead of restoring a global-DB boundary.
🤖 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/agent/sandbox/manager.go` around lines 168 - 169, The runtime
LoadFromSettings entry point currently hard-codes dao.DB, preventing
caller-owned database or transaction use. Update
ProviderManager.LoadFromSettings to accept a *gorm.DB parameter and pass it to
LoadFromSettingsWithReader; update the owning ManagerClient.ExecuteCode call
path to provide its active database handle.
Signed-off-by: Jin Hai <[email protected]>
No description provided.