chore: use zod v3 syntax#4851
Conversation
|
@himself65 is attempting to deploy a commit to the better-auth Team on Vercel. A member of the Team first needs to authorize it. |
better-auth
@better-auth/cli
@better-auth/expo
@better-auth/sso
@better-auth/stripe
commit: |
There was a problem hiding this comment.
13 issues found across 37 files
Prompt for AI agents (all 13 issues)
Understand the root cause of the following 13 issues and fix them.
<file name="packages/better-auth/src/plugins/organization/routes/crud-invites.ts">
<violation number="1" location="packages/better-auth/src/plugins/organization/routes/crud-invites.ts:847">
Rule violated: **Enforce Consistent Naming Conventions**
Use a descriptive parameter name for consistency and clarity; replace generic id with invitationId to align with other endpoints and naming conventions.</violation>
</file>
<file name="packages/better-auth/src/plugins/organization/routes/crud-access-control.ts">
<violation number="1" location="packages/better-auth/src/plugins/organization/routes/crud-access-control.ts:75">
Description text truncated mid-sentence; restore full message for clarity.</violation>
<violation number="2" location="packages/better-auth/src/plugins/organization/routes/crud-access-control.ts:606">
Description text truncated mid-sentence; restore full message for clarity.</violation>
<violation number="3" location="packages/better-auth/src/plugins/organization/routes/crud-access-control.ts:764">
Description text truncated mid-sentence; restore full message for clarity.</violation>
</file>
<file name="packages/better-auth/src/plugins/generic-oauth/index.ts">
<violation number="1" location="packages/better-auth/src/plugins/generic-oauth/index.ts:358">
Incomplete description string: the example is missing after "Eg:". Provide a concrete example or remove the placeholder.</violation>
</file>
<file name="packages/better-auth/src/plugins/organization/routes/crud-members.ts">
<violation number="1" location="packages/better-auth/src/plugins/organization/routes/crud-members.ts:410">
Incomplete description string; trailing 'Eg: [' indicates a truncated example. Clean up or complete the text.</violation>
</file>
<file name="packages/better-auth/src/plugins/organization/routes/crud-team.ts">
<violation number="1" location="packages/better-auth/src/plugins/organization/routes/crud-team.ts:563">
Typo in example: "organziation-id" should be "organization-id".</violation>
</file>
<file name="packages/better-auth/src/plugins/one-time-token/index.ts">
<violation number="1" location="packages/better-auth/src/plugins/one-time-token/index.ts:132">
Zod describe string is incomplete (ends with "Eg:"), reducing clarity for docs; include an example or remove the "Eg:".</violation>
</file>
<file name="packages/sso/src/index.ts">
<violation number="1" location="packages/sso/src/index.ts:342">
Truncated .describe() texts in oidcConfig.mapping (dangling '(' and missing defaults) degrade API docs clarity.</violation>
</file>
<file name="packages/better-auth/src/plugins/device-authorization/index.ts">
<violation number="1" location="packages/better-auth/src/plugins/device-authorization/index.ts:625">
Error enum for /device missing "expired_token", which this endpoint returns when the user code is expired.</violation>
</file>
<file name="packages/better-auth/src/plugins/two-factor/otp/index.ts">
<violation number="1" location="packages/better-auth/src/plugins/two-factor/otp/index.ts:137">
Incomplete description string; it ends mid-sentence. Restore the full sentence and example for clarity in generated docs.</violation>
</file>
<file name="packages/better-auth/src/plugins/admin/admin.ts">
<violation number="1" location="packages/better-auth/src/plugins/admin/admin.ts:501">
Invalid Zod record key schema: use a string-like key (e.g., z.string()) instead of z.any() for z.record().</violation>
<violation number="2" location="packages/better-auth/src/plugins/admin/admin.ts:606">
Attach description to the union schema instead of a single branch to document the full (string | number | boolean) type.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| id: z.string().meta({ | ||
| description: "The ID of the invitation to get", | ||
| }), | ||
| id: z.string().describe("The ID of the invitation to get"), |
There was a problem hiding this comment.
Rule violated: Enforce Consistent Naming Conventions
Use a descriptive parameter name for consistency and clarity; replace generic id with invitationId to align with other endpoints and naming conventions.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/organization/routes/crud-invites.ts at line 847:
<comment>Use a descriptive parameter name for consistency and clarity; replace generic id with invitationId to align with other endpoints and naming conventions.</comment>
<file context>
@@ -869,9 +844,7 @@ export const getInvitation = <O extends OrganizationOptions>(options: O) =>
- id: z.string().meta({
- description: "The ID of the invitation to get",
- }),
+ id: z.string().describe("The ID of the invitation to get"),
}),
metadata: {
</file context>
| .string() | ||
| .optional() | ||
| .describe( | ||
| "The id of the organization to create the role in. If not provided, the user", |
There was a problem hiding this comment.
Description text truncated mid-sentence; restore full message for clarity.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/organization/routes/crud-access-control.ts at line 75:
<comment>Description text truncated mid-sentence; restore full message for clarity.</comment>
<file context>
@@ -68,16 +68,16 @@ export const createOrgRole = <O extends OrganizationOptions>(options: O) => {
+ .string()
+ .optional()
+ .describe(
+ "The id of the organization to create the role in. If not provided, the user",
+ ),
+ role: z.string().describe("The name of the role to create"),
</file context>
| .string() | ||
| .optional() | ||
| .describe( | ||
| "The id of the organization to read a role for. If not provided, the user", |
There was a problem hiding this comment.
Description text truncated mid-sentence; restore full message for clarity.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/organization/routes/crud-access-control.ts at line 606:
<comment>Description text truncated mid-sentence; restore full message for clarity.</comment>
<file context>
@@ -599,22 +599,20 @@ export const getOrgRole = <O extends OrganizationOptions>(options: O) => {
+ .string()
+ .optional()
+ .describe(
+ "The id of the organization to read a role for. If not provided, the user",
+ ),
})
</file context>
| .string() | ||
| .optional() | ||
| .describe( | ||
| "The id of the organization to update the role in. If not provided, the user", |
There was a problem hiding this comment.
Description text truncated mid-sentence; restore full message for clarity.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/organization/routes/crud-access-control.ts at line 764:
<comment>Description text truncated mid-sentence; restore full message for clarity.</comment>
<file context>
@@ -759,34 +757,31 @@ export const updateOrgRole = <O extends OrganizationOptions>(options: O) => {
+ .string()
+ .optional()
+ .describe(
+ "The id of the organization to update the role in. If not provided, the user",
+ ),
data: z.object({
</file context>
| 'The URL to redirect to after login if the user is new. Eg: "/welcome"', | ||
| }) | ||
| .describe( | ||
| "The URL to redirect to after login if the user is new. Eg: ", |
There was a problem hiding this comment.
Incomplete description string: the example is missing after "Eg:". Provide a concrete example or remove the placeholder.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/generic-oauth/index.ts at line 358:
<comment>Incomplete description string: the example is missing after "Eg:". Provide a concrete example or remove the placeholder.</comment>
<file context>
@@ -341,47 +341,38 @@ export const genericOAuth = (options: GenericOAuthOptions) => {
- 'The URL to redirect to after login if the user is new. Eg: "/welcome"',
- })
+ .describe(
+ "The URL to redirect to after login if the user is new. Eg: ",
+ )
.optional(),
</file context>
| "The URL to redirect to after login if the user is new. Eg: ", | |
| "The URL to redirect to after login if the user is new. Eg: \"/welcome\"", |
| description: | ||
| "Field mapping for image (defaults to 'picture')", | ||
| }) | ||
| .describe("Field mapping for image (") |
There was a problem hiding this comment.
Truncated .describe() texts in oidcConfig.mapping (dangling '(' and missing defaults) degrade API docs clarity.
Prompt for AI agents
Address the following comment on packages/sso/src/index.ts at line 342:
<comment>Truncated .describe() texts in oidcConfig.mapping (dangling '(' and missing defaults) degrade API docs clarity.</comment>
<file context>
@@ -284,95 +284,62 @@ export const sso = (options?: SSOOptions) => {
- description:
- "Field mapping for image (defaults to 'picture')",
- })
+ .describe("Field mapping for image (")
.optional(),
extraFields: z.record(z.string(), z.any()).optional(),
</file context>
| error_description: z.string().meta({ | ||
| description: "Detailed error description", | ||
| }), | ||
| error: z.enum(["invalid_request"]).describe("Error code"), |
There was a problem hiding this comment.
Error enum for /device missing "expired_token", which this endpoint returns when the user code is expired.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/device-authorization/index.ts at line 625:
<comment>Error enum for /device missing "expired_token", which this endpoint returns when the user code is expired.</comment>
<file context>
@@ -631,17 +619,13 @@ Follow [rfc8628#section-3.4](https://datatracker.ietf.org/doc/html/rfc8628#secti
- error_description: z.string().meta({
- description: "Detailed error description",
- }),
+ error: z.enum(["invalid_request"]).describe("Error code"),
+ error_description: z
+ .string()
</file context>
| error: z.enum(["invalid_request"]).describe("Error code"), | |
| error: z.enum(["invalid_request", "expired_token"]).describe("Error code"), |
| trustDevice: z | ||
| .boolean() | ||
| .optional() | ||
| .describe("If true, the device will be trusted for 30 days. It"), |
There was a problem hiding this comment.
Incomplete description string; it ends mid-sentence. Restore the full sentence and example for clarity in generated docs.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/two-factor/otp/index.ts at line 137:
<comment>Incomplete description string; it ends mid-sentence. Restore the full sentence and example for clarity in generated docs.</comment>
<file context>
@@ -131,10 +131,10 @@ export const otp2fa = (options?: OTPOptions) => {
+ trustDevice: z
+ .boolean()
+ .optional()
+ .describe("If true, the device will be trusted for 30 days. It"),
})
.optional(),
</file context>
| .meta({ | ||
| description: "The value to filter by", | ||
| }) | ||
| .describe("The value to filter by") |
There was a problem hiding this comment.
Attach description to the union schema instead of a single branch to document the full (string | number | boolean) type.
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/admin/admin.ts at line 606:
<comment>Attach description to the union schema instead of a single branch to document the full (string | number | boolean) type.</comment>
<file context>
@@ -584,68 +566,50 @@ export const admin = <O extends AdminOptions>(options?: O) => {
- .meta({
- description: "The value to filter by",
- })
+ .describe("The value to filter by")
.or(z.number())
.or(z.boolean())
</file context>
| }), | ||
| userId: z.coerce.string().describe("The user id"), | ||
| data: z | ||
| .record(z.any(), z.any()) |
There was a problem hiding this comment.
Invalid Zod record key schema: use a string-like key (e.g., z.string()) instead of z.any() for z.record().
Prompt for AI agents
Address the following comment on packages/better-auth/src/plugins/admin/admin.ts at line 501:
<comment>Invalid Zod record key schema: use a string-like key (e.g., z.string()) instead of z.any() for z.record().</comment>
<file context>
@@ -512,12 +496,10 @@ export const admin = <O extends AdminOptions>(options?: O) => {
- }),
+ userId: z.coerce.string().describe("The user id"),
+ data: z
+ .record(z.any(), z.any())
+ .describe("The user data to update"),
}),
</file context>
| .record(z.any(), z.any()) | |
| .record(z.string(), z.any()) |
This reverts commit 7fa0c2d.
This reverts commit 7fa0c2d.
This reverts commit 7fa0c2d.
This reverts commit 7fa0c2d.
This reverts commit 7fa0c2d.
This reverts commit 7fa0c2d.
Document: https://zod.dev/metadata?id=describe
Fixes: #4837
Summary by cubic
Migrated all endpoint and plugin schemas to Zod v3 syntax to standardize descriptions and improve consistency. No runtime behavior changes; API inputs and outputs remain the same.
Refactors
Migration