Fix AdminErrors camelCase mismatch (#296)#298
Conversation
The ErrorLogEntry interface used snake_case property names (error_type, stack_trace, first_occurrence, occurrence_count) but Drizzle ORM returns camelCase keys, so these fields were always undefined in the UI. https://claude.ai/code/session_01KSAniF3KMZDuS3TBoqdUqF
Replace the local ErrorLogEntry interface with a mapped type derived from the shared ErrorLog schema, preventing future snake_case/camelCase drift. Fix context nullability check for unknown type from jsonb. Add regression test verifying camelCase field alignment with schema. https://claude.ai/code/session_01KSAniF3KMZDuS3TBoqdUqF
📝 WalkthroughWalkthroughThis PR fixes a camelCase/snake_case property name mismatch in the AdminErrors page. It adds a test file to validate ErrorLog schema field alignment and updates the component to use camelCase property names ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 the current code and only fix it if needed.
Inline comments:
In `@client/src/pages/AdminErrors.test.ts`:
- Around line 28-44: Add a tracking issue to cover missing component-level tests
for AdminErrors.tsx: create an issue titled like "Add AdminErrors component
tests" and include a clear checklist of test cases to implement (loading state
rendering, error state rendering, empty logs array handling, and batch
selection/deletion flows), reference the existing AdminErrors.tsx component and
AdminErrors.test.ts for schema checks, and note recommended tools (React Testing
Library + Jest) and any props/APIs to mock (data fetching hook or props used by
AdminErrors) so future PRs can implement each scenario.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: c3fca4f4-be81-4a37-8a5d-f7f83b105bbc
📒 Files selected for processing (2)
client/src/pages/AdminErrors.test.tsclient/src/pages/AdminErrors.tsx
| it("schema exports camelCase field names used by AdminErrors", () => { | ||
| // These are the fields AdminErrors.tsx references — if the schema | ||
| // renames them, this array literal will cause a TS error and the | ||
| // runtime check below will also catch it. | ||
| expect(schemaKeys).toContain("errorType"); | ||
| expect(schemaKeys).toContain("stackTrace"); | ||
| expect(schemaKeys).toContain("firstOccurrence"); | ||
| expect(schemaKeys).toContain("occurrenceCount"); | ||
| }); | ||
|
|
||
| it("schema does NOT export snake_case names", () => { | ||
| const keys = schemaKeys as string[]; | ||
| expect(keys).not.toContain("error_type"); | ||
| expect(keys).not.toContain("stack_trace"); | ||
| expect(keys).not.toContain("first_occurrence"); | ||
| expect(keys).not.toContain("occurrence_count"); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider expanding test coverage for functional edge cases.
While this schema alignment test is effective for its purpose, the AdminErrors component itself lacks test coverage for:
- Loading state rendering
- Error state rendering
- Empty logs array handling
- Batch selection/deletion flows
This is outside the scope of the current fix, but worth tracking separately.
Do you want me to open an issue to track adding component-level tests for AdminErrors.tsx?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@client/src/pages/AdminErrors.test.ts` around lines 28 - 44, Add a tracking
issue to cover missing component-level tests for AdminErrors.tsx: create an
issue titled like "Add AdminErrors component tests" and include a clear
checklist of test cases to implement (loading state rendering, error state
rendering, empty logs array handling, and batch selection/deletion flows),
reference the existing AdminErrors.tsx component and AdminErrors.test.ts for
schema checks, and note recommended tools (React Testing Library + Jest) and any
props/APIs to mock (data fetching hook or props used by AdminErrors) so future
PRs can implement each scenario.
Summary
The AdminErrors page used snake_case property names (
error_type,stack_trace,first_occurrence,occurrence_count) in its localErrorLogEntryinterface, but Drizzle ORM returns camelCase keys (errorType,stackTrace,firstOccurrence,occurrenceCount). This caused four UI elements to silently never render — error type badges, occurrence count badges, date ranges, and stack traces.Fixes #296.
Changes
ErrorLogEntryinterface with a mapped type derived from the sharedErrorLogschema (shared/schema.ts), preventing future snake_case/camelCase driftlog.errorType,log.stackTrace,log.firstOccurrence,log.occurrenceCount){log.context && (to{log.context != null && (to handle theunknowntype from jsonb correctlyAdminErrors.test.tsverifying the camelCase field names in the shared schema match what the component expectsHow to test
errorType,occurrenceCount > 1, or astackTracein the databasenpm run check && npm run test— all 1896 tests passhttps://claude.ai/code/session_01KSAniF3KMZDuS3TBoqdUqF
Summary by CodeRabbit
Tests
Refactor
Bug Fixes