Skip to content

go mod fixes - updates dashboard migrations#2190

Merged
akshaydeo merged 1 commit intomainfrom
03-21-go_mod_fixes_-_updates_dashboard_migrations
Mar 22, 2026
Merged

go mod fixes - updates dashboard migrations#2190
akshaydeo merged 1 commit intomainfrom
03-21-go_mod_fixes_-_updates_dashboard_migrations

Conversation

@akshaydeo
Copy link
Copy Markdown
Contributor

@akshaydeo akshaydeo commented Mar 20, 2026

Summary

Updates Go dependencies across all modules to their latest versions, including golang.org/x packages, Google Cloud libraries, and third-party dependencies like buger/jsonparser and cel.dev/expr.

Changes

  • Updated golang.org/x packages (term: v0.40.0→v0.41.0, sys: v0.41.0→v0.42.0, text: v0.33.0→v0.35.0, crypto: v0.47.0→v0.49.0, net: v0.49.0→v0.52.0, sync: v0.19.0→v0.20.0)
  • Updated Google Cloud and gRPC dependencies (grpc: v1.78.0→v1.79.3, genproto/googleapis/rpc with newer timestamps)
  • Updated third-party libraries (buger/jsonparser: v1.1.1→v1.1.2, cel.dev/expr: v0.24.0→v0.25.1)
  • Refactored dashboard enhancement migration to defer expensive operations (backfill and index rebuild) to background processing
  • Added new advisory lock mechanism for dashboard enhancements to prevent concurrent execution across cluster nodes
  • Split migration into lightweight schema change (adding cached_read_tokens column) and heavy background work (data backfill, index operations)

Type of change

  • Chore/CI
  • Refactor

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Plugins

How to test

Verify dependency updates and migration behavior:

# Verify builds succeed with updated dependencies
go version
go test ./...

# Test migration behavior (PostgreSQL only)
# 1. Start with existing data
# 2. Run migration - should complete quickly
# 3. Verify cached_read_tokens column exists but is initially 0
# 4. Background process should eventually backfill data and rebuild indexes

The migration changes are PostgreSQL-specific and designed to be non-blocking for pod startup.

Breaking changes

  • Yes
  • No

Related issues

Routine dependency maintenance to keep packages current with security patches and bug fixes.

Security considerations

Dependency updates include security patches from the Go standard library and third-party packages. The migration refactoring improves system stability by preventing long-running database operations from blocking application startup.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b20c98f-7766-4d13-8d61-52bb1d2b34c7

📥 Commits

Reviewing files that changed from the base of the PR and between da62438 and 8c647b1.

⛔ Files ignored due to path filters (13)
  • cli/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • framework/go.sum is excluded by !**/*.sum
  • plugins/governance/go.sum is excluded by !**/*.sum
  • plugins/jsonparser/go.sum is excluded by !**/*.sum
  • plugins/litellmcompat/go.sum is excluded by !**/*.sum
  • plugins/logging/go.sum is excluded by !**/*.sum
  • plugins/maxim/go.sum is excluded by !**/*.sum
  • plugins/mocker/go.sum is excluded by !**/*.sum
  • plugins/otel/go.sum is excluded by !**/*.sum
  • plugins/semanticcache/go.sum is excluded by !**/*.sum
  • plugins/telemetry/go.sum is excluded by !**/*.sum
  • transports/go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • cli/go.mod
  • core/go.mod
  • framework/go.mod
  • framework/logstore/migrations.go
  • framework/logstore/postgres.go
  • plugins/governance/go.mod
  • plugins/jsonparser/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/logging/go.mod
  • plugins/maxim/go.mod
  • plugins/mocker/go.mod
  • plugins/otel/go.mod
  • plugins/semanticcache/go.mod
  • plugins/telemetry/go.mod
  • transports/go.mod
  • ui/app/workspace/logs/views/logsVolumeChart.tsx
✅ Files skipped from review due to trivial changes (13)
  • framework/go.mod
  • cli/go.mod
  • plugins/mocker/go.mod
  • plugins/jsonparser/go.mod
  • plugins/governance/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/logging/go.mod
  • plugins/semanticcache/go.mod
  • transports/go.mod
  • plugins/otel/go.mod
  • plugins/telemetry/go.mod
  • core/go.mod
  • plugins/maxim/go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/app/workspace/logs/views/logsVolumeChart.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Dashboard enhancements now run asynchronously after startup, performing non-blocking data backfill and index maintenance so the service remains available while improvements complete.
  • Style
    • Adjusted chart layout margins to improve spacing and presentation of log volume charts.
  • Chores
    • Bumped numerous Go module dependency versions across the repository for upstream fixes and compatibility.

Walkthrough

Bumps many Go module versions and moves expensive dashboard backfill/index work out of migrations into an asynchronous, advisory-locked background routine run after startup.

Changes

Cohort / File(s) Summary
Go module updates
cli/go.mod, core/go.mod, framework/go.mod, plugins/governance/go.mod, plugins/jsonparser/go.mod, plugins/litellmcompat/go.mod, plugins/logging/go.mod, plugins/maxim/go.mod, plugins/mocker/go.mod, plugins/otel/go.mod, plugins/semanticcache/go.mod, plugins/telemetry/go.mod, transports/go.mod
Bumped indirect/transitive dependencies across modules (examples: github.com/buger/jsonparser v1.1.1→v1.1.2, multiple golang.org/x/* upgrades, gRPC/genproto bumps). No public API changes.
Dashboard enhancements / Postgres migrations
framework/logstore/migrations.go, framework/logstore/postgres.go
Added advisory-lock key and acquireDashboardEnhancementsLock; migration reduced to only adding cached_read_tokens; introduced ensureDashboardEnhancements() to idempotently backfill cached_read_tokens and rebuild indexes using DROP/CREATE INDEX CONCURRENTLY IF EXISTS/NOT EXISTS; newPostgresLogStore spawns a non-blocking goroutine to run ensureDashboardEnhancements() after migrations.
UI chart spacing
ui/app/workspace/logs/views/logsVolumeChart.tsx
Added a margin prop to the BarChart (top:6,right:4,left:12,bottom:0) to adjust internal drawing/layout spacing.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Startup as Startup/Migrations
    participant Store as PostgresLogStore
    participant BG as DashboardEnhancer (goroutine)
    participant Lock as AdvisoryLock
    participant DB as PostgreSQL

    Startup->>Store: run migrations (blocking)
    Store-->>Startup: migrations complete (returns store)
    Store->>BG: spawn ensureDashboardEnhancements() (non-blocking)

    BG->>Lock: acquire advisory lock
    Lock->>DB: pg_try_advisory_lock/request
    DB-->>Lock: grant lock to one node
    Lock-->>BG: lock acquired

    BG->>DB: UPDATE ... SET cached_read_tokens = ... WHERE cached_read_tokens = 0 AND COALESCE(...) > 0
    DB-->>BG: rows updated
    BG->>DB: CHECK pg_index.indisvalid for idx_logs_histogram_cover / idx_mcp_logs_histogram_cover
    DB-->>BG: validity results
    BG->>DB: DROP INDEX CONCURRENTLY IF EXISTS ... (if invalid)
    DB-->>BG: index dropped
    BG->>DB: CREATE INDEX CONCURRENTLY ... (recreate or create if missing)
    DB-->>BG: index created
    BG-->>Store: log success or warn on error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through go.mod with a cheerful bite,

Pushed heavy work to night’s soft light.
One little lock keeps chaos at bay,
Backfills and indexes hum away.
I nibble a carrot — deployment’s in sight.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'go mod fixes - updates dashboard migrations' accurately summarizes the main changes: dependency updates and dashboard migration refactoring.
Description check ✅ Passed The description is clearly related to the changeset, providing detailed explanation of dependency updates and migration refactoring with testing guidance.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 03-21-go_mod_fixes_-_updates_dashboard_migrations

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor Author

akshaydeo commented Mar 20, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Test Suite Available

This PR can be tested by a repository admin.

Run tests for PR #2190

@akshaydeo akshaydeo marked this pull request as ready for review March 20, 2026 20:51
@coderabbitai coderabbitai Bot requested a review from danpiths March 20, 2026 20:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
framework/logstore/migrations.go (1)

1993-2012: Consider using CREATE INDEX CONCURRENTLY to avoid blocking writes.

The index recreation (lines 1997-2004) and MCP index creation (lines 2007-2012) use standard CREATE INDEX which acquires an exclusive lock, blocking writes during the build. On large tables, this could cause write latency spikes.

For consistency with ensureMetadataGINIndex and ensurePerformanceIndexes, consider using CREATE INDEX CONCURRENTLY. This would require dropping the existing index with DROP INDEX CONCURRENTLY IF EXISTS as well.

That said, the current approach still achieves the primary goal of not blocking pod startup, and the B-tree index build should be relatively fast compared to GIN indexes.

♻️ Optional: Use CONCURRENTLY for index operations
-	if err := db.WithContext(ctx).Exec("DROP INDEX IF EXISTS idx_logs_histogram_cover").Error; err != nil {
+	if err := db.WithContext(ctx).Exec("DROP INDEX CONCURRENTLY IF EXISTS idx_logs_histogram_cover").Error; err != nil {
 		return fmt.Errorf("failed to drop old covering index: %w", err)
 	}
-	createLogsIndexSQL := `CREATE INDEX IF NOT EXISTS idx_logs_histogram_cover ON logs(
+	createLogsIndexSQL := `CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_logs_histogram_cover ON logs(
 		status, timestamp,
 		selected_key_id, virtual_key_id, routing_rule_id, provider, object_type,
 		model, cost, prompt_tokens, completion_tokens, total_tokens, cached_read_tokens
 	)`
 	if err := db.WithContext(ctx).Exec(createLogsIndexSQL).Error; err != nil {
 		return fmt.Errorf("failed to create updated covering index: %w", err)
 	}

 	// Create MCP histogram covering index if missing.
-	createMCPIndexSQL := `CREATE INDEX IF NOT EXISTS idx_mcp_logs_histogram_cover ON mcp_tool_logs(
+	createMCPIndexSQL := `CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_mcp_logs_histogram_cover ON mcp_tool_logs(
 		status, timestamp, tool_name, server_label, virtual_key_id, cost
 	)`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/logstore/migrations.go` around lines 1993 - 2012, The index
creation/dropping in this migration uses blocking statements; change the DROP
and CREATE statements to use CONCURRENTLY (i.e., "DROP INDEX CONCURRENTLY IF
EXISTS idx_logs_histogram_cover" and "CREATE INDEX CONCURRENTLY IF NOT EXISTS
idx_logs_histogram_cover" and similarly for idx_mcp_logs_histogram_cover) so
writes aren't blocked during builds; update the Exec calls in this migration
function (the block that constructs createLogsIndexSQL and createMCPIndexSQL and
their preceding DROP) and ensure error handling remains the same (keep the same
fmt.Errorf messages) while using the CONCURRENTLY variants.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@framework/logstore/migrations.go`:
- Around line 1993-2012: The index creation/dropping in this migration uses
blocking statements; change the DROP and CREATE statements to use CONCURRENTLY
(i.e., "DROP INDEX CONCURRENTLY IF EXISTS idx_logs_histogram_cover" and "CREATE
INDEX CONCURRENTLY IF NOT EXISTS idx_logs_histogram_cover" and similarly for
idx_mcp_logs_histogram_cover) so writes aren't blocked during builds; update the
Exec calls in this migration function (the block that constructs
createLogsIndexSQL and createMCPIndexSQL and their preceding DROP) and ensure
error handling remains the same (keep the same fmt.Errorf messages) while using
the CONCURRENTLY variants.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e6d0c316-1544-4d1c-a490-c5efdcca8af7

📥 Commits

Reviewing files that changed from the base of the PR and between 50c7566 and 18846cc.

⛔ Files ignored due to path filters (13)
  • cli/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • framework/go.sum is excluded by !**/*.sum
  • plugins/governance/go.sum is excluded by !**/*.sum
  • plugins/jsonparser/go.sum is excluded by !**/*.sum
  • plugins/litellmcompat/go.sum is excluded by !**/*.sum
  • plugins/logging/go.sum is excluded by !**/*.sum
  • plugins/maxim/go.sum is excluded by !**/*.sum
  • plugins/mocker/go.sum is excluded by !**/*.sum
  • plugins/otel/go.sum is excluded by !**/*.sum
  • plugins/semanticcache/go.sum is excluded by !**/*.sum
  • plugins/telemetry/go.sum is excluded by !**/*.sum
  • transports/go.sum is excluded by !**/*.sum
📒 Files selected for processing (15)
  • cli/go.mod
  • core/go.mod
  • framework/go.mod
  • framework/logstore/migrations.go
  • framework/logstore/postgres.go
  • plugins/governance/go.mod
  • plugins/jsonparser/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/logging/go.mod
  • plugins/maxim/go.mod
  • plugins/mocker/go.mod
  • plugins/otel/go.mod
  • plugins/semanticcache/go.mod
  • plugins/telemetry/go.mod
  • transports/go.mod

@akshaydeo akshaydeo force-pushed the 03-21-go_mod_fixes_-_updates_dashboard_migrations branch from 18846cc to 3d406f8 Compare March 20, 2026 23:55
@akshaydeo akshaydeo mentioned this pull request Mar 20, 2026
18 tasks
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@framework/logstore/migrations.go`:
- Around line 1984-1991: The backfill currently treats cached_read_tokens = 0 as
"not backfilled", which conflicts with 0 being a valid final value; change the
sentinel to NULL (or another distinct marker) so rows that truly have 0 aren't
repeatedly processed: update the backfillSQL variable to filter WHERE
cached_read_tokens IS NULL (instead of = 0) and ensure any schema/default logic
sets the column default to 0 while leaving existing unbackfilled rows as NULL
(or explicitly set NULL for pre-backfill rows), so the Exec in migrations.go
only updates NULL entries and subsequent runs become no-ops.
- Around line 1994-2011: Replace the blocking index statements with concurrent
ones: change the DROP INDEX and CREATE INDEX SQL for idx_logs_histogram_cover
and idx_mcp_logs_histogram_cover (the strings assigned to createLogsIndexSQL and
createMCPIndexSQL and the Exec calls that run them via db.WithContext(ctx).Exec)
to use DROP INDEX CONCURRENTLY and CREATE INDEX CONCURRENTLY; ensure these Exec
calls are not executed inside a transaction (Postgres forbids CONCURRENTLY
inside a transaction), so remove or avoid any surrounding transaction context
for these statements and handle/log any errors as before.
🪄 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

Run ID: 2402e5cf-5f32-47b1-8cec-74e39c36a23f

📥 Commits

Reviewing files that changed from the base of the PR and between 18846cc and 3d406f8.

⛔ Files ignored due to path filters (13)
  • cli/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • framework/go.sum is excluded by !**/*.sum
  • plugins/governance/go.sum is excluded by !**/*.sum
  • plugins/jsonparser/go.sum is excluded by !**/*.sum
  • plugins/litellmcompat/go.sum is excluded by !**/*.sum
  • plugins/logging/go.sum is excluded by !**/*.sum
  • plugins/maxim/go.sum is excluded by !**/*.sum
  • plugins/mocker/go.sum is excluded by !**/*.sum
  • plugins/otel/go.sum is excluded by !**/*.sum
  • plugins/semanticcache/go.sum is excluded by !**/*.sum
  • plugins/telemetry/go.sum is excluded by !**/*.sum
  • transports/go.sum is excluded by !**/*.sum
📒 Files selected for processing (15)
  • cli/go.mod
  • core/go.mod
  • framework/go.mod
  • framework/logstore/migrations.go
  • framework/logstore/postgres.go
  • plugins/governance/go.mod
  • plugins/jsonparser/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/logging/go.mod
  • plugins/maxim/go.mod
  • plugins/mocker/go.mod
  • plugins/otel/go.mod
  • plugins/semanticcache/go.mod
  • plugins/telemetry/go.mod
  • transports/go.mod
✅ Files skipped from review due to trivial changes (12)
  • framework/go.mod
  • plugins/mocker/go.mod
  • plugins/jsonparser/go.mod
  • cli/go.mod
  • plugins/telemetry/go.mod
  • core/go.mod
  • plugins/maxim/go.mod
  • plugins/logging/go.mod
  • plugins/governance/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/otel/go.mod
  • plugins/semanticcache/go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • transports/go.mod

Comment thread framework/logstore/migrations.go
Comment thread framework/logstore/migrations.go Outdated
@akshaydeo akshaydeo force-pushed the 03-21-go_mod_fixes_-_updates_dashboard_migrations branch from 3d406f8 to 5fe923c Compare March 21, 2026 11:06
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
framework/logstore/migrations.go (1)

1939-1943: Inconsistent argument style for AddColumn.

Line 1940 uses the struct field name "CachedReadTokens" while all other migrations in this file use the snake_case column name (e.g., "parent_request_id", "responses_output", "cost"). While GORM accepts either form, using the column name would be consistent with the established pattern.

Proposed fix for consistency
 			if !dbMigrator.HasColumn(&Log{}, "cached_read_tokens") {
-				if err := dbMigrator.AddColumn(&Log{}, "CachedReadTokens"); err != nil {
+				if err := dbMigrator.AddColumn(&Log{}, "cached_read_tokens"); err != nil {
 					return fmt.Errorf("failed to add cached_read_tokens column: %w", err)
 				}
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/logstore/migrations.go` around lines 1939 - 1943, The migration
uses AddColumn with the struct field name "CachedReadTokens" which is
inconsistent with other migrations that use snake_case column names; update the
AddColumn call on dbMigrator for the Log model to use "cached_read_tokens"
(i.e., replace "CachedReadTokens" with "cached_read_tokens") so it matches the
existing convention used for columns like "parent_request_id" and
"responses_output".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@framework/logstore/migrations.go`:
- Around line 1939-1943: The migration uses AddColumn with the struct field name
"CachedReadTokens" which is inconsistent with other migrations that use
snake_case column names; update the AddColumn call on dbMigrator for the Log
model to use "cached_read_tokens" (i.e., replace "CachedReadTokens" with
"cached_read_tokens") so it matches the existing convention used for columns
like "parent_request_id" and "responses_output".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7129a1d-db31-420b-b6aa-93df7ab2528f

📥 Commits

Reviewing files that changed from the base of the PR and between 3d406f8 and 5fe923c.

⛔ Files ignored due to path filters (13)
  • cli/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • framework/go.sum is excluded by !**/*.sum
  • plugins/governance/go.sum is excluded by !**/*.sum
  • plugins/jsonparser/go.sum is excluded by !**/*.sum
  • plugins/litellmcompat/go.sum is excluded by !**/*.sum
  • plugins/logging/go.sum is excluded by !**/*.sum
  • plugins/maxim/go.sum is excluded by !**/*.sum
  • plugins/mocker/go.sum is excluded by !**/*.sum
  • plugins/otel/go.sum is excluded by !**/*.sum
  • plugins/semanticcache/go.sum is excluded by !**/*.sum
  • plugins/telemetry/go.sum is excluded by !**/*.sum
  • transports/go.sum is excluded by !**/*.sum
📒 Files selected for processing (15)
  • cli/go.mod
  • core/go.mod
  • framework/go.mod
  • framework/logstore/migrations.go
  • framework/logstore/postgres.go
  • plugins/governance/go.mod
  • plugins/jsonparser/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/logging/go.mod
  • plugins/maxim/go.mod
  • plugins/mocker/go.mod
  • plugins/otel/go.mod
  • plugins/semanticcache/go.mod
  • plugins/telemetry/go.mod
  • transports/go.mod
✅ Files skipped from review due to trivial changes (11)
  • framework/go.mod
  • cli/go.mod
  • plugins/jsonparser/go.mod
  • plugins/logging/go.mod
  • plugins/mocker/go.mod
  • plugins/otel/go.mod
  • transports/go.mod
  • plugins/telemetry/go.mod
  • plugins/litellmcompat/go.mod
  • core/go.mod
  • plugins/governance/go.mod
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/maxim/go.mod
  • plugins/semanticcache/go.mod

@akshaydeo akshaydeo force-pushed the 03-21-go_mod_fixes_-_updates_dashboard_migrations branch from 5fe923c to da62438 Compare March 21, 2026 11:43
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
framework/logstore/migrations.go (1)

1946-1952: ⚠️ Potential issue | 🟡 Minor

Don't swallow rollback failures.

This is the only rollback in the surrounding migrations that discards DropColumn errors. If the drop fails, the migrator will still report success while the schema is unchanged.

Suggested fix
 		Rollback: func(tx *gorm.DB) error {
 			tx = tx.WithContext(ctx)
 			dbMigrator := tx.Migrator()

 			if dbMigrator.HasColumn(&Log{}, "cached_read_tokens") {
-				_ = dbMigrator.DropColumn(&Log{}, "cached_read_tokens")
+				if err := dbMigrator.DropColumn(&Log{}, "cached_read_tokens"); err != nil {
+					return err
+				}
 			}
 			return nil
 		},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/logstore/migrations.go` around lines 1946 - 1952, The rollback
currently swallows errors from dbMigrator.DropColumn inside the Rollback func
(tx *gorm.DB) error, so a failed drop of the "cached_read_tokens" column on
Log{} will be ignored; change it to capture the returned error from
dbMigrator.DropColumn(&Log{}, "cached_read_tokens") and return that error (or
wrap it) instead of discarding it so the migrator reports failure when the drop
fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@framework/logstore/migrations.go`:
- Around line 1995-2014: The migration currently always drops/recreates
idx_logs_histogram_cover and blindly runs CREATE INDEX CONCURRENTLY for
idx_mcp_logs_histogram_cover; instead adopt the same pattern used in
ensureMetadataGINIndex/ensurePerformanceIndexes: for each index
(idx_logs_histogram_cover on logs and idx_mcp_logs_histogram_cover on
mcp_tool_logs) query pg_index.indisvalid (joining pg_class/pg_index) to
determine if the index exists and is valid, skip creation when valid, otherwise
DROP INDEX CONCURRENTLY IF EXISTS to remove invalid remnants, then run the
CREATE INDEX CONCURRENTLY SQL; implement this logic around the
createLogsIndexSQL and createMCPIndexSQL blocks so valid indexes are not rebuilt
and interrupted concurrent builds are cleaned before creating.

---

Outside diff comments:
In `@framework/logstore/migrations.go`:
- Around line 1946-1952: The rollback currently swallows errors from
dbMigrator.DropColumn inside the Rollback func (tx *gorm.DB) error, so a failed
drop of the "cached_read_tokens" column on Log{} will be ignored; change it to
capture the returned error from dbMigrator.DropColumn(&Log{},
"cached_read_tokens") and return that error (or wrap it) instead of discarding
it so the migrator reports failure when the drop fails.
🪄 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

Run ID: c242bd5b-14c6-4e39-b423-50eba617c648

📥 Commits

Reviewing files that changed from the base of the PR and between 5fe923c and da62438.

⛔ Files ignored due to path filters (13)
  • cli/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • framework/go.sum is excluded by !**/*.sum
  • plugins/governance/go.sum is excluded by !**/*.sum
  • plugins/jsonparser/go.sum is excluded by !**/*.sum
  • plugins/litellmcompat/go.sum is excluded by !**/*.sum
  • plugins/logging/go.sum is excluded by !**/*.sum
  • plugins/maxim/go.sum is excluded by !**/*.sum
  • plugins/mocker/go.sum is excluded by !**/*.sum
  • plugins/otel/go.sum is excluded by !**/*.sum
  • plugins/semanticcache/go.sum is excluded by !**/*.sum
  • plugins/telemetry/go.sum is excluded by !**/*.sum
  • transports/go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • cli/go.mod
  • core/go.mod
  • framework/go.mod
  • framework/logstore/migrations.go
  • framework/logstore/postgres.go
  • plugins/governance/go.mod
  • plugins/jsonparser/go.mod
  • plugins/litellmcompat/go.mod
  • plugins/logging/go.mod
  • plugins/maxim/go.mod
  • plugins/mocker/go.mod
  • plugins/otel/go.mod
  • plugins/semanticcache/go.mod
  • plugins/telemetry/go.mod
  • transports/go.mod
  • ui/app/workspace/logs/views/logsVolumeChart.tsx
✅ Files skipped from review due to trivial changes (13)
  • ui/app/workspace/logs/views/logsVolumeChart.tsx
  • framework/go.mod
  • cli/go.mod
  • plugins/mocker/go.mod
  • plugins/jsonparser/go.mod
  • core/go.mod
  • plugins/maxim/go.mod
  • plugins/logging/go.mod
  • plugins/semanticcache/go.mod
  • plugins/governance/go.mod
  • plugins/otel/go.mod
  • plugins/telemetry/go.mod
  • plugins/litellmcompat/go.mod
🚧 Files skipped from review as they are similar to previous changes (2)
  • framework/logstore/postgres.go
  • transports/go.mod

Comment thread framework/logstore/migrations.go Outdated
@akshaydeo akshaydeo force-pushed the 03-21-go_mod_fixes_-_updates_dashboard_migrations branch from da62438 to 8c647b1 Compare March 22, 2026 07:25
Copy link
Copy Markdown
Contributor Author

akshaydeo commented Mar 22, 2026

Merge activity

  • Mar 22, 7:52 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 22, 7:52 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo merged commit 9dfdf5f into main Mar 22, 2026
7 of 9 checks passed
@akshaydeo akshaydeo deleted the 03-21-go_mod_fixes_-_updates_dashboard_migrations branch March 22, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants