[GH-ISSUE #2387] verification table: value too long for type character varying(255) #9175

Closed
opened 2026-04-13 04:32:34 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @afrokick on GitHub (Apr 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2387

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I'm trying to implement linkSocial API, but get this PG error:

error: value too long for type character varying(255)

I've started digging how it works:

  1. https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/api/routes/account.ts#L167

linkSocial endpoint calls generateState function with email and userId.

  1. https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/oauth2/state.ts#L21

generateState function creates a string via JSON.stringify. This string is more than 255 characters.

An example of test object(322 characters):

JSON.stringify({
		callbackURL:'',
		codeVerifier:'CVL1rHarg4buiN56D4Q43zW23m8Kaqp6wMUZRVjqefqntciFqu5BR29GRyBpHHDZ1AFHzQYMhtKbY6bv5aVx7WFpXJHn8wjh3DeFPWXhT6ynLjqX4XeCPu7iXFrUkSMa',
		errorURL: '',
		newUserURL: '',
		link: {
				email:'myemail@test.com',
				userId:'VKBFSCDMURZNXDMLOCAEVKBEQATVFKCA'
		},
		expiresAt: Date.now() + 10 * 60 * 1000,
		requestSignUp: false
})
  1. I've checked the database and realised that verification.value column has a max 255char size.

It can be manually fixed by increasing column size for verification.value column, but it would be nice to have a good default size for this column.

Current vs. Expected behavior

Values with more than 255 chars should work without database errors.

What version of Better Auth are you using?

1.2.3

Provide environment information

- bun 1.2
- Postgres 16

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)


Additional context

No response

Originally created by @afrokick on GitHub (Apr 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2387 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I'm trying to implement linkSocial API, but get this PG error: ``` error: value too long for type character varying(255) ``` I've started digging how it works: 1. https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/api/routes/account.ts#L167 linkSocial endpoint calls generateState function with email and userId. 2. https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/oauth2/state.ts#L21 generateState function creates a string via JSON.stringify. This string is more than 255 characters. An example of test object(322 characters): ``` JSON.stringify({ callbackURL:'', codeVerifier:'CVL1rHarg4buiN56D4Q43zW23m8Kaqp6wMUZRVjqefqntciFqu5BR29GRyBpHHDZ1AFHzQYMhtKbY6bv5aVx7WFpXJHn8wjh3DeFPWXhT6ynLjqX4XeCPu7iXFrUkSMa', errorURL: '', newUserURL: '', link: { email:'myemail@test.com', userId:'VKBFSCDMURZNXDMLOCAEVKBEQATVFKCA' }, expiresAt: Date.now() + 10 * 60 * 1000, requestSignUp: false }) ``` 3. I've checked the database and realised that `verification.value` column has a max 255char size. It can be manually fixed by increasing column size for `verification.value` column, but it would be nice to have a good default size for this column. ### Current vs. Expected behavior Values with more than 255 chars should work without database errors. ### What version of Better Auth are you using? 1.2.3 ### Provide environment information ```bash - bun 1.2 - Postgres 16 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 04:32:34 -05:00
Author
Owner

@Kinfe123 commented on GitHub (May 31, 2025):

can you please share the column type of the current pg database for values ?
You should check the actual column type of verification.value in your database. Even though it's defined as text in the schema, some databases (like MySQL or SQLite) or ORMs (e.g. Prisma) may implicitly map it to VARCHAR(255) unless explicitly specified.

TEXT in most databases (e.g., PostgreSQL) can store very large values

<!-- gh-comment-id:2925749402 --> @Kinfe123 commented on GitHub (May 31, 2025): can you please share the column type of the current pg database for values ? You should check the actual column type of verification.value in your database. Even though it's defined as text in the schema, some databases (like MySQL or SQLite) or ORMs (e.g. Prisma) may implicitly map it to VARCHAR(255) unless explicitly specified. TEXT in most databases (e.g., PostgreSQL) can store very large values
Author
Owner

@afrokick commented on GitHub (Jun 1, 2025):

It was set to character varying(255) for verification.value. I've manually changed it to character varying(1024) to fix the problem.

I use Postgres + Knex.

<!-- gh-comment-id:2926732968 --> @afrokick commented on GitHub (Jun 1, 2025): It was set to `character varying(255)` for `verification.value`. I've manually changed it to `character varying(1024)` to fix the problem. I use Postgres + Knex.
Author
Owner

@SkidGod4444 commented on GitHub (Jun 25, 2025):

It was set to character varying(255) for verification.value. I've manually changed it to character varying(1024) to fix the problem.

I use Postgres + Knex.

how you did this can you pls guide? am using supabase @afrokick

<!-- gh-comment-id:3004086029 --> @SkidGod4444 commented on GitHub (Jun 25, 2025): > It was set to `character varying(255)` for `verification.value`. I've manually changed it to `character varying(1024)` to fix the problem. > > I use Postgres + Knex. how you did this can you pls guide? am using supabase @afrokick
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9175