Skip to content

Fix AdminErrors camelCase mismatch (#296)#298

Merged
bd73-com merged 2 commits intomainfrom
claude/fix-github-issues-aTyWH
Mar 28, 2026
Merged

Fix AdminErrors camelCase mismatch (#296)#298
bd73-com merged 2 commits intomainfrom
claude/fix-github-issues-aTyWH

Conversation

@bd73-com
Copy link
Copy Markdown
Owner

@bd73-com bd73-com commented Mar 27, 2026

Summary

The AdminErrors page used snake_case property names (error_type, stack_trace, first_occurrence, occurrence_count) in its local ErrorLogEntry interface, 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

  • Interface alignment: Replaced the hand-maintained local ErrorLogEntry interface with a mapped type derived from the shared ErrorLog schema (shared/schema.ts), preventing future snake_case/camelCase drift
  • JSX property accesses: Updated all 8 property accesses from snake_case to camelCase (log.errorType, log.stackTrace, log.firstOccurrence, log.occurrenceCount)
  • Type safety: Changed {log.context && ( to {log.context != null && ( to handle the unknown type from jsonb correctly
  • Regression test: Added AdminErrors.test.ts verifying the camelCase field names in the shared schema match what the component expects

How to test

  1. Ensure there are error log entries with a non-null errorType, occurrenceCount > 1, or a stackTrace in the database
  2. Log in as a power-tier user or the app owner
  3. Navigate to the admin error logs page
  4. Verify: error type text appears next to the source badge
  5. Verify: occurrence count badge (e.g. "3x") appears for recurring errors
  6. Verify: date range (first occurrence — last occurrence) displays for recurring errors
  7. Verify: stack trace section renders in the expanded view
  8. Run npm run check && npm run test — all 1896 tests pass

https://claude.ai/code/session_01KSAniF3KMZDuS3TBoqdUqF

Summary by CodeRabbit

  • Tests

    • Added test validation to ensure error log fields remain properly aligned with schema definitions.
  • Refactor

    • Updated error display properties to use consistent naming conventions.
  • Bug Fixes

    • Improved context rendering logic in error logs to properly display information when values are present.

claude added 2 commits March 27, 2026 15:47
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
@github-actions github-actions bot added the fix label Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This 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 (errorType, stackTrace, firstOccurrence, occurrenceCount) matching the Drizzle ORM schema, ensuring error details render correctly.

Changes

Cohort / File(s) Summary
Test Coverage
client/src/pages/AdminErrors.test.ts
New test file validating that ErrorLog schema uses camelCase properties and rejecting snake_case variants. Uses keyof ErrorLog type assertion to catch schema renames at compile time and runtime assertions to verify expected field presence.
Component Fix
client/src/pages/AdminErrors.tsx
Updated ErrorLogEntry type to derive from ErrorLog schema with Date-to-string mapping. Replaced all snake_case property accesses with camelCase equivalents (error_typeerrorType, stack_tracestackTrace, first_occurrencefirstOccurrence, occurrence_countoccurrenceCount). Changed context rendering condition from truthy check to explicit null check (log.context != null).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix AdminErrors camelCase mismatch (#296)' accurately summarizes the primary change: correcting the snake_case/camelCase property name mismatch in the AdminErrors component.
Linked Issues check ✅ Passed The PR fully addresses issue #296 by replacing snake_case property names with camelCase, updating all JSX usages, fixing the context nullability check, and adding a regression test to prevent future drift.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the camelCase mismatch in AdminErrors; the new test file validates schema alignment without introducing unrelated modifications.

✏️ 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 claude/fix-github-issues-aTyWH

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.

❤️ Share

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

Copy link
Copy Markdown

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 23ff187 and 8d477b9.

📒 Files selected for processing (2)
  • client/src/pages/AdminErrors.test.ts
  • client/src/pages/AdminErrors.tsx

Comment on lines +28 to +44
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");
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 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.

@bd73-com bd73-com merged commit e39b40f into main Mar 28, 2026
2 checks passed
@github-actions github-actions bot deleted the claude/fix-github-issues-aTyWH branch March 28, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: AdminErrors page never displays error_type, stack_trace, or occurrence_count due to camelCase mismatch

2 participants