Skip to content

Conversation

Copy link

Copilot AI commented Jan 17, 2026

OAuth providers (notably Google) issue tokens exceeding 255 characters, causing SQLSTATE[22001]: String data, right truncated errors on token storage.

Changes

  • New migration 2026_01_17_000001_update_twill_oauth_token_column.php changes token column from VARCHAR(255) to TEXT
  • Rollback protection validates no tokens exceed 255 chars before allowing reversion, preventing silent data truncation
  • Existing migration preserved to maintain backward compatibility

The migration only executes when twill.enabled.users-oauth is enabled and the table exists, safe for both fresh and existing installations.

// Before: VARCHAR(255) with index
$table->string('token')->index();

// After: TEXT without index constraint
$table->text('token')->change();
Original prompt

This section details on the original issue you should resolve

<issue_title>OAuth Token Length Exceeds Database Column Limit</issue_title>
<issue_description>## Description
I'm experiencing a database error when using OAuth authentication with Twill. The OAuth tokens being generated are longer than the current 255-character limit set for the token column in the twill_users_oauth table, causing SQL errors during token storage.

The error occurs when attempting to store OAuth tokens that exceed the VARCHAR(255) limit defined in the migration file.

Steps to reproduce

  1. Enable OAuth authentication in Twill configuration (twill.enabled.users-oauth = true)
  2. Set up OAuth provider (the specific provider may vary, but tokens can be lengthy)
  3. Attempt to authenticate via OAuth
  4. The authentication process fails when trying to store the token in the database

Expected result

OAuth tokens should be successfully stored in the database regardless of their length, allowing users to authenticate properly through OAuth providers.

Actual result

The following SQL error is thrown:

Error 500 SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'token' at row 1 
(Connection: mysql, SQL: update `twill_users_oauth` set `token` = 
ya29.A0EXAMPLE_TOKEN_HERE_THAT_IS_VERY_LONG_AND_EXCEEDS_255_CHARACTERS_LIMIT_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890, 
`twill_users_oauth`.`updated_at` = 2025-06-24 16:24:58 where `id` = 3)

Versions

  • Twill version: 3.1.0
  • Laravel version: 10.39.0
  • Database engine: MariaDB
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 3 commits January 17, 2026 14:52
Co-authored-by: ifox <708498+ifox@users.noreply.github.com>
Co-authored-by: ifox <708498+ifox@users.noreply.github.com>
Co-authored-by: ifox <708498+ifox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix OAuth token length exceeds database column limit Expand OAuth token column from VARCHAR(255) to TEXT Jan 17, 2026
Copilot AI requested a review from ifox January 17, 2026 14:57
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.

OAuth Token Length Exceeds Database Column Limit

3 participants