-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Replace any types in parser and error handling #1083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- parser.ts: Added ParsedWorkflowData, ParsedNode, ParsedEdge interfaces with type guards for proper YAML parsing. Replaced 9 any casts. - database-error-patterns.ts: Added DatabaseError interface and isDatabaseError type guard. Updated categorizeErrorWithProvider and isRetryableWithProvider to use unknown with proper type guards. Replaced 8+ any casts. - speech-to-text.ts: Added WarehouseMetric and WarehouseAssignment interfaces for proper typing of experiment data. Replaced 7 any casts. - ingest.ts: Used proper ChromaDB Collection and Metadata types. Replaced 6 any casts. - db/route.ts: Removed unnecessary type assertions on dynamic imports, used Record<string, unknown> for raw query results. Replaced 6 any casts. Total: 36 any casts eliminated across 5 files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 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 |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
PR Analysis 📊Changed Files Summary:
CI Status: Running automated checks... |
Dependency Audit Results |
Quick Checks Results
✅ All quick checks passed! |
🔒 Security Audit Results✅ Secret Scanning: No secrets detected 📊 View full results: Security Audit Summary |
Build Status ✅ Build successful✅ Build completed successfully! |
Test Results ✅ PassedTest Suites: 2 skipped, 343 passed, 343 of 345 total ✅ All tests passed! Ready for review. View test outputCheck the Actions tab for detailed test output. |
PR Status Summary
✅ All checks passed! This PR is ready to merge. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request aims to improve TypeScript type safety by replacing 36 explicit as any casts with proper interfaces, type guards, and helper functions across 5 TypeScript files. However, the PR also includes two unrelated Go files that are not mentioned in the description.
Changes:
- Added proper TypeScript interfaces and type guards for YAML parsing, database error handling, experiment metrics, ChromaDB operations, and health check results
- Introduced new Go module configuration and CLI backup file (unrelated to the main purpose)
- Improved type safety across workflow parser, database error patterns, experiments, and API routes
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/cli/go.mod | New Go module file with invalid version number (1.25.6 doesn't exist) |
| tools/cli/cmd/vibecode-demo/main.go.bak | Backup file added (406 lines) - should not be committed |
| src/lib/workflow/parser.ts | Added ParsedWorkflowData/Node/Edge interfaces, type guards, and validation logic |
| src/lib/vector-db/database-error-patterns.ts | Added DatabaseError interface with type guards for safe property access |
| src/lib/experiments/scenarios/speech-to-text.ts | Added WarehouseMetric and WarehouseAssignment interfaces for type safety |
| src/lib/ai/documentation/ingest.ts | Improved ChromaDB types with Collection and Metadata interfaces - contains critical bug |
| src/app/api/health/db/route.ts | Removed unnecessary as any casts from dynamic imports and query results |
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "log" | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/charmbracelet/bubbles/list" | ||
| "github.com/charmbracelet/bubbles/progress" | ||
| "github.com/charmbracelet/bubbles/spinner" | ||
| tea "github.com/charmbracelet/bubbletea" | ||
| "github.com/charmbracelet/lipgloss" | ||
| "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" | ||
| ) | ||
|
|
||
| const ( | ||
| // Colors | ||
| primaryColor = lipgloss.Color("#00D9FF") // Datadog blue | ||
| successColor = lipgloss.Color("#00C851") // Success green | ||
| warningColor = lipgloss.Color("#FF8800") // Warning orange | ||
| errorColor = lipgloss.Color("#FF4444") // Error red | ||
| subtleColor = lipgloss.Color("#666666") // Subtle gray | ||
| ) | ||
|
|
||
| var ( | ||
| titleStyle = lipgloss.NewStyle(). | ||
| Foreground(primaryColor). | ||
| Bold(true). | ||
| Padding(0, 1) | ||
|
|
||
| subtitleStyle = lipgloss.NewStyle(). | ||
| Foreground(subtleColor). | ||
| Italic(true) | ||
|
|
||
| successStyle = lipgloss.NewStyle(). | ||
| Foreground(successColor). | ||
| Bold(true) | ||
|
|
||
| errorStyle = lipgloss.NewStyle(). | ||
| Foreground(errorColor). | ||
| Bold(true) | ||
|
|
||
| warningStyle = lipgloss.NewStyle(). | ||
| Foreground(warningColor). | ||
| Bold(true) | ||
|
|
||
| boxStyle = lipgloss.NewStyle(). | ||
| Border(lipgloss.RoundedBorder()). | ||
| BorderForeground(primaryColor). | ||
| Padding(1, 2). | ||
| Margin(1, 0) | ||
| ) | ||
|
|
||
| type screen int | ||
|
|
||
| const ( | ||
| menuScreen screen = iota | ||
| statusScreen | ||
| setupScreen | ||
| demoScreen | ||
| helpScreen | ||
| ) | ||
|
|
||
| type menuItem struct { | ||
| title string | ||
| description string | ||
| action string | ||
| } | ||
|
|
||
| func (m menuItem) Title() string { return m.title } | ||
| func (m menuItem) Description() string { return m.description } | ||
| func (m menuItem) FilterValue() string { return m.title } | ||
|
|
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backup files (with .bak extension) should generally not be committed to version control. This file appears to be a backup of main.go and should either be removed from the commit or the file should be renamed appropriately if it's meant to be a permanent part of the codebase.
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "os" | |
| "os/exec" | |
| "strings" | |
| "time" | |
| "github.com/charmbracelet/bubbles/list" | |
| "github.com/charmbracelet/bubbles/progress" | |
| "github.com/charmbracelet/bubbles/spinner" | |
| tea "github.com/charmbracelet/bubbletea" | |
| "github.com/charmbracelet/lipgloss" | |
| "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" | |
| ) | |
| const ( | |
| // Colors | |
| primaryColor = lipgloss.Color("#00D9FF") // Datadog blue | |
| successColor = lipgloss.Color("#00C851") // Success green | |
| warningColor = lipgloss.Color("#FF8800") // Warning orange | |
| errorColor = lipgloss.Color("#FF4444") // Error red | |
| subtleColor = lipgloss.Color("#666666") // Subtle gray | |
| ) | |
| var ( | |
| titleStyle = lipgloss.NewStyle(). | |
| Foreground(primaryColor). | |
| Bold(true). | |
| Padding(0, 1) | |
| subtitleStyle = lipgloss.NewStyle(). | |
| Foreground(subtleColor). | |
| Italic(true) | |
| successStyle = lipgloss.NewStyle(). | |
| Foreground(successColor). | |
| Bold(true) | |
| errorStyle = lipgloss.NewStyle(). | |
| Foreground(errorColor). | |
| Bold(true) | |
| warningStyle = lipgloss.NewStyle(). | |
| Foreground(warningColor). | |
| Bold(true) | |
| boxStyle = lipgloss.NewStyle(). | |
| Border(lipgloss.RoundedBorder()). | |
| BorderForeground(primaryColor). | |
| Padding(1, 2). | |
| Margin(1, 0) | |
| ) | |
| type screen int | |
| const ( | |
| menuScreen screen = iota | |
| statusScreen | |
| setupScreen | |
| demoScreen | |
| helpScreen | |
| ) | |
| type menuItem struct { | |
| title string | |
| description string | |
| action string | |
| } | |
| func (m menuItem) Title() string { return m.title } | |
| func (m menuItem) Description() string { return m.description } | |
| func (m menuItem) FilterValue() string { return m.title } | |
| // Deprecated backup file for tools/cli/cmd/vibecode-demo/main.go. | |
| // This .bak file should not be kept under version control and is | |
| // intentionally left empty. Please remove it from the repository. |
| }; | ||
| // Copy additional metadata fields (only primitive types) | ||
| for (const [key, value] of Object.entries(doc.metadata)) { | ||
| if (![source, 'chunkIndex', 'timestamp'].includes(key)) { |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug in metadata filtering logic: The condition uses [source, 'chunkIndex', 'timestamp'].includes(key) but source is the function parameter (a string value like "github.com"), not the string literal 'source'. This should be ['source', 'chunkIndex', 'timestamp'].includes(key) with 'source' as a string literal, otherwise the filter will incorrectly exclude metadata fields.
| if (![source, 'chunkIndex', 'timestamp'].includes(key)) { | |
| if (!['source', 'chunkIndex', 'timestamp'].includes(key)) { |
| * Type-safe accessor for node config properties | ||
| */ | ||
| function getConfigProperty<T>(config: NodeConfig, key: string): T | undefined { | ||
| return (config as Record<string, unknown>)[key] as T | undefined; |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getConfigProperty helper function may not provide proper type safety because NodeConfig is a union type. TypeScript cannot guarantee that the property exists on the union without type narrowing. A safer approach would be to add type narrowing within each case block or use type guards for each config type. For example, in the 'agent-task' case, narrow the type to AgentTaskConfig before accessing properties.
| * Type-safe accessor for node config properties | |
| */ | |
| function getConfigProperty<T>(config: NodeConfig, key: string): T | undefined { | |
| return (config as Record<string, unknown>)[key] as T | undefined; | |
| * Helper to safely access properties on a generic config object | |
| */ | |
| function getConfigProperty<T>(config: Record<string, unknown> | undefined, key: string): T | undefined { | |
| if (!config) return undefined; | |
| return config[key] as T | undefined; |
| module vibecode-cli | ||
|
|
||
| go 1.25.6 |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description states "Eliminates 36 explicit as any casts across 5 high-impact files" but the PR also includes two Go files (tools/cli/go.mod and tools/cli/cmd/vibecode-demo/main.go.bak) that are not mentioned in the description. These files appear to be unrelated to the TypeScript type safety improvements described in the PR. Consider whether these Go files should be in a separate PR or if the PR description should be updated to reflect all changes.
Summary
as anycasts across 5 high-impact filesChanges
src/lib/workflow/parser.ts(9 → 0) - Added workflow data interfaces, type guards for YAML parsingsrc/lib/vector-db/database-error-patterns.ts(8 → 0) - Added DatabaseError interface and type guardssrc/lib/experiments/scenarios/speech-to-text.ts(7 → 0) - Added WarehouseMetric/Assignment interfacessrc/lib/ai/documentation/ingest.ts(6 → 0) - Proper ChromaDB Collection and Metadata typessrc/app/api/health/db/route.ts(6 → 0) - Removed unnecessary casts, proper result typingTest plan
🤖 Generated with Claude Code