fix(validation): add missing analytics date range schema - #662
Conversation
|
@r69shabh is attempting to deploy a commit to the Databuddy OSS Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR restores the missing
Confidence Score: 4/5The PR should not merge until partial date ranges are either rejected or consistently honored downstream, because currently a caller can receive analytics for an unintended default period. The new schema repairs the package export and correctly validates complete ISO date ranges, but it also accepts single-ended ranges that downstream procedures discard in favor of their default date window. Files Needing Attention: packages/validation/src/schemas/analytics.ts Important Files Changed
Reviews (1): Last reviewed commit: "fix(validation): add missing analytics d..." | Re-trigger Greptile |
| startDate: analyticsDateOnlySchema.optional(), | ||
| endDate: analyticsDateOnlySchema.optional(), |
There was a problem hiding this comment.
Partial ranges are silently discarded
When an MCP analytics request supplies only from or only to, this schema accepts the incomplete range, but the downstream procedure requires both endpoints and replaces it with its default seven-day range, returning analytics for dates the caller did not request.
Partial ranges (only startDate or only endDate) were accepted by the schema but silently replaced with a default range downstream, returning analytics for dates the caller did not request. Require both endpoints or neither.
Summary
bb15bd61f(feat(mcp): expand public workspace tool contract) addedpackages/ai/src/ai/mcp/tool-contracts.ts, which importsanalyticsDateRangeSchemafrom@databuddy/validation— but the schema was never added to the package. This breaks the module graph at test time:This causes an unhandled error in the
@databuddy/aitest suite (1 error, tests after it in the affected file fail).Changes
analyticsDateRangeSchematopackages/validation/src/schemas/analytics.ts: optionalstartDate/endDateISO date (YYYY-MM-DD) fields with a cross-field refinement thatstartDatemust be on or beforeendDate(reported as acustomissue, matching whattool-contracts.tsforwards into its ownsuperRefine).Verification
packages/validation: 83 passpackages/ai: 3705 pass, 0 fail (previously crashed on import)Found while rebasing #642 onto staging.
Summary by cubic
Adds
analyticsDateRangeSchemato@databuddy/validationto match the MCP tool contract in@databuddy/ai, fixing import errors and test crashes. Previously, partial ranges (only startDate or only endDate) were accepted and defaulted downstream; now the schema requires both dates or none, validates ISOYYYY-MM-DD, and enforces startDate <= endDate.startDateandendDate; otherwise omit both.Written for commit fb5a3fa. Summary will update on new commits.