-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove COUNTRY_CODES from OpenAPI spec #2748
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
WalkthroughSchema validations were loosened from COUNTRY_CODES enums to strings across analytics, links, and partner creation. A local schema added an optional country filter for AI-generated analytics filters. Cron verification removed a development bypass, now always enforcing Authorization header checks against CRON_SECRET. Changes
Sequence Diagram(s)sequenceDiagram
participant VercelCron as Vercel Cron
participant API as verifyVercel()
participant Secrets as Env (CRON_SECRET)
VercelCron->>API: HTTP request with Authorization header
API->>Secrets: Read CRON_SECRET
alt Missing or mismatch
API-->>VercelCron: 401 DubApiError "Invalid QStash request signature"
else Match
API-->>VercelCron: Proceed to handler (verified)
end
Estimated code review effortπ― 3 (Moderate) | β±οΈ ~15 minutes Possibly related PRs
Poem
β¨ Finishing Touches
π§ͺ Generate unit tests
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. πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
apps/web/lib/ai/generate-filters.ts (1)
14-31: Consider the schema merge approach and polyfill comment.The implementation creates a polyfill for the country field with enum validation while the main analytics schema uses string validation. This creates inconsistency in validation logic between the two schemas.
Consider these alternatives:
- Use the same validation approach (string) in both schemas for consistency
- If enum validation is truly needed here, document why this schema requires stricter validation than the main analytics schema
Apply this diff for consistency with the main schema:
- country: z - .enum(COUNTRY_CODES) - .optional() - .describe( - "The country to retrieve analytics for. Must be passed as a 2-letter ISO 3166-1 country code. See https://d.to/geo for more information.", - ), + country: z + .string() + .optional() + .describe( + "The country to retrieve analytics for. Must be passed as a 2-letter ISO 3166-1 country code. See https://d.to/geo for more information.", + ),
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (5)
apps/web/lib/ai/generate-filters.ts(1 hunks)apps/web/lib/cron/verify-vercel.ts(1 hunks)apps/web/lib/zod/schemas/analytics.ts(1 hunks)apps/web/lib/zod/schemas/links.ts(2 hunks)apps/web/lib/zod/schemas/partners.ts(1 hunks)
π§° Additional context used
𧬠Code Graph Analysis (1)
apps/web/lib/ai/generate-filters.ts (2)
apps/web/lib/zod/schemas/analytics.ts (1)
analyticsQuerySchema(69-254)apps/web/lib/analytics/constants.ts (1)
VALID_ANALYTICS_FILTERS(157-187)
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
π Additional comments (7)
apps/web/lib/zod/schemas/analytics.ts (1)
147-153: LGTM! Country validation has been loosened appropriately.The change from
z.enum(COUNTRY_CODES)toz.string()for the country field aligns with the PR objective to remove strict country code validation from the OpenAPI spec while maintaining the descriptive guidance for users.apps/web/lib/cron/verify-vercel.ts (1)
5-7: LGTM! Development bypass correctly removed.The commented-out VERCEL bypass ensures that cron verification now always enforces Authorization header checks against CRON_SECRET, improving security by removing the development-only exception.
apps/web/lib/ai/generate-filters.ts (1)
6-9: Both imports are used β keep themThe imports are required in apps/web/lib/ai/generate-filters.ts:
- import { COUNTRY_CODES } from "@dub/utils" β used in z.enum(COUNTRY_CODES)
- import z from "../zod" β used to build/merge the schema (z.object / z.enum)
No change needed.
apps/web/lib/zod/schemas/links.ts (2)
378-384: LGTM! Geo targeting validation properly loosened.The change from
z.record(z.enum(COUNTRY_CODES), parseUrlSchema)toz.record(z.string(), parseUrlSchema)increateLinkBodySchema.geocorrectly removes the strict country code validation while maintaining the URL validation for geo-targeting values.
621-626: LGTM! LinkSchema geo field validation updated consistently.The change from
z.record(z.enum(COUNTRY_CODES), z.string().url())toz.record(z.string(), z.string().url())maintains consistency with the create schema changes.apps/web/lib/zod/schemas/partners.ts (2)
387-392: LGTM! Partner country validation loosened consistently.The change from
z.enum(COUNTRY_CODES)toz.string()for thecreatePartnerSchema.countryfield aligns with the overall PR objective to remove strict country code validation.
441-472: Note: Intentional validation inconsistency in onboard schema.The
onboardPartnerSchema.countryfield on Line 451 continues to usez.enum(COUNTRY_CODES)whilecreatePartnerSchema.countrynow usesz.string(). This appears intentional based on the AI summary, likely because onboarding requires stricter validation for compliance purposes.
Summary by CodeRabbit
New Features
Chores