Skip to content

submit mutation rejects current ccusage output: daily entries now use period instead of date (Invalid date format: undefined)#50

Closed
dprvda wants to merge 1 commit into
sculptdotfun:mainfrom
dprvda:fix/ccusage-period-date-field
Closed

submit mutation rejects current ccusage output: daily entries now use period instead of date (Invalid date format: undefined)#50
dprvda wants to merge 1 commit into
sculptdotfun:mainfrom
dprvda:fix/ccusage-period-date-field

Conversation

@dprvda

@dprvda dprvda commented Jun 1, 2026

Copy link
Copy Markdown

Fixes #49.

Problem

Current ccusage --json emits each daily entry keyed by period (plus agent/metadata) instead of date. The submit mutation reads day.date, which is now undefined, so submissions fail with Invalid date format: undefined. Expected YYYY-MM-DD. None of the ingestion paths (packages/viberank-cli/cli.js, src/app/api/submit/route.ts, submit-to-viberank.sh) normalize this, so the fix lives at the single chokepoint they all funnel through: convex/submissions.ts.

Change (convex/submissions.ts, +19/βˆ’7)

  1. Widen the daily args validator β€” date becomes optional and period/agent/metadata are accepted as optional. Convex v.object is strict, so without this it rejects the real payload before the handler runs.
  2. Coalesce day.date ?? day.period in the validation loop and at every incoming-date read plus both stored-write paths (merge + insert), so dailyBreakdown.date is always a valid YYYY-MM-DD.

convex/schema.ts (stored date: v.string(), required) is intentionally left unchanged β€” period is normalized to date at ingestion.

Verification

  • Type-neutral β€” typechecking the convex/ sources before and after the patch yields the same result; it introduces no new type errors. Please confirm with your usual convex deploy / tsc.
  • End-to-end on a real failing cc.json (32 daily entries, all keyed by period): pre-change throws the exact reported error; post-change all 32 pass and store valid dates (range 2026-05-01..2026-06-01).

Coordination notes

πŸ€– Generated with Claude Code

Recent ccusage `--json` emits each daily entry keyed by `period` (plus
`agent`/`metadata`) instead of `date`. The submit mutation reads
`day.date`, which is now undefined, so every submission fails with
"Invalid date format: undefined. Expected YYYY-MM-DD".

Widen the daily args validator to accept the new optional fields, and
coalesce `day.date ?? day.period` at every incoming-date read and at both
stored-write paths, so submissions are accepted and `dailyBreakdown.date`
is always a valid YYYY-MM-DD string.

Type-neutral (introduces no new tsc errors); verified end-to-end against a
real failing cc.json (32 daily entries, all keyed by `period`).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown

@dprvda is attempting to deploy a commit to the sculpt Team on Vercel.

A member of the Team first needs to authorize it.

@nikshepsvn

Copy link
Copy Markdown
Contributor

Thanks for this β€” your diagnosis of the period vs date regression and the failing payload were spot on, and they directly informed the fix.

The one catch: production runs on Supabase, not the Convex backend this PR patches (Convex was a dormant fallback in the tree). So the real submission path never hit convex/submissions.ts β€” the fix had to land in the Supabase path. viberank v2 (#51) implements it there, normalizing every ccusage report shape at a single chokepoint, and also removes the dormant Convex backend entirely so this kind of wrong-target confusion can't happen again.

Closing as superseded by #51 β€” but genuinely appreciate you surfacing the root cause. πŸ™

@nikshepsvn nikshepsvn closed this Jun 9, 2026
livlign pushed a commit to livlign/viberank that referenced this pull request Jun 9, 2026
Convex was dead code behind a feature flag (production has always run on
Supabase). It's also what misled PR sculptdotfun#50 into patching the wrong backend.
Removing it makes the data layer single-backend and removes the confusion.

- delete convex/, convex.json, src/lib/data/convex/
- strip Convex branches from the data-layer factory and the submission/
  profile/stats hooks; Supabase is the only path
- providers.tsx: drop ConvexProvider; env/turbo: drop CONVEX_* vars
- drop convex + @convex-dev/rate-limiter deps (Supabase rate-limiter
  already replaced the latter)
- DatabaseBackend type narrowed to "supabase"

Build green, tests pass, no live convex references remain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

submit mutation rejects current ccusage output: daily entries now use period instead of date (Invalid date format: undefined)

2 participants