supabase-flutter icon indicating copy to clipboard operation
supabase-flutter copied to clipboard

[Bug]: supabase_flutter: 2.9.1 throws FormatException on login when device language is non-ASCII (e.g., Korean)

Open kthguru opened this issue 1 year ago • 4 comments

Describe the bug Since updating supabase_flutter from 2.9.0 to 2.9.1, users whose device language is set to a non-ASCII language (like Korean) can no longer log in or perform any action that makes a request to the Supabase backend. For example, Platform.operatingSystemVersion shows Korean version text (e.g., 버전 15.5(빌드 24F74) on macOS.

The action fails with a FormatException: Invalid HTTP header field value. This is caused by the new X-Supabase-Client-Platform-Version header, which was added in version 2.9.1. This header includes the device's OS version string directly. When the device language is set to Korean, the OS version string contains non-ASCII characters (e.g., 버전 15.5(빌드 24F74)), which are not valid in an HTTP header value according to RFC 7230.

Perhaps this feature was likely introduced in commit as follows:

  • Commit: Feat: Add standard client headers f33c9fe2f67fc83d19904a53e0b71e7cec5cee53
  • PR: #1130

To Reproduce Steps to reproduce the behavior:

  1. Set the physical device's or emulator's system language to Korean (한국어).
  2. Create a Flutter project using supabase_flutter: 2.9.1.
  3. Attempt to call any Supabase authentication method, such as Supabase.instance.client.auth.signInWithPassword(...).
  4. See the FormatException error thrown by Dart's HTTP client.

or

// The following shows Korean version text (e.g., 버전 15.5(빌드 24F74)
print('Platform.operatingSystemVersion = ${Platform.operatingSystemVersion}');

final koreanOSVersion = '버전 15.5(빌드 24F74)';
final englishOSVersion = 'Version 15.5 (Build 24F74)';

await Supabase.initialize(
    headers: {
      // 'X-Supabase-Client-Platform-Version': koreanOSVersion, // Error: FormatException: Invalid HTTP header field value
      'X-Supabase-Client-Platform-Version': englishOSVersion, // Succeed to login without any errors.
    },

Expected behavior The authentication process should complete successfully, regardless of the device's system language. The X-Supabase-Client-Platform-Version header should be properly encoded or sanitized to ensure it only contains valid ASCII characters before being sent.

Screenshots

  • Here is the error message from the console: FormatException: Invalid HTTP header field value: "버전 15.5(빌드 24F74)" (at character 1)
  • Here is the error message from the gui: Image

Version (please complete the following information): On macOS Please run dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client" in your project directory and paste the output here.

supabase_flutter: 2.9.0

├── supabase_auth_ui 0.5.5
│   └── supabase_flutter...
├── supabase_flutter 2.9.0
│   ├── supabase 2.7.0
│   │   ├── functions_client 2.4.2
│   │   ├── gotrue 2.12.0
│   │   ├── postgrest 2.4.2
│   │   ├── realtime_client 2.5.0
│   │   ├── storage_client 2.4.0

supabase_flutter: 2.9.1

├── supabase_auth_ui 0.5.5
│   └── supabase_flutter...
├── supabase_flutter 2.9.1
│   ├── supabase 2.8.0
│   │   ├── functions_client 2.4.3
│   │   ├── gotrue 2.13.0
│   │   ├── postgrest 2.4.2
│   │   ├── realtime_client 2.5.1
│   │   ├── storage_client 2.4.0

On Linux Please run dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client" in your project directory and paste the output here.

On Windows Please run dart pub deps | findstr "supabase gotrue postgrest storage_client realtime_client functions_client" in your project directory and paste the output here.

Additional context Add any other context about the problem here.

  • This is a regression bug introduced in 2.9.1.
  • The last known working version is 2.9.0, as it did not have the feature to send the X-Supabase-Client-Platform-Version header.
  • The current workaround is to downgrade and pin the version in pubspec.yaml: supabase_flutter: 2.9.0.

kthguru avatar Jun 12 '25 20:06 kthguru

Encountered the same error:

ERROR: AuthRetryableFetchException(message: FormatException: Invalid HTTP header field value: "\"Windows 11 专业版\" 10.0 (Build 26100)" (at character 13)
"Windows 11 专业版" 10.0 (Build 26100)
            ^
, statusCode: null)

lihenggui avatar Jun 19 '25 05:06 lihenggui

The same error for devices with Russian language.

yegor-pelykh avatar Jun 22 '25 07:06 yegor-pelykh

Encountered the same error:

ERROR: AuthRetryableFetchException(message: FormatException: Invalid HTTP header field value: "\"Windows 11 专业版\" 10.0 (Build 26100)" (at character 13)
"Windows 11 专业版" 10.0 (Build 26100)
            ^
, statusCode: null)

I encountered the same problem

Meterwhite avatar Jul 04 '25 10:07 Meterwhite

@dshukertjr May you release a new version, please?

Vinzent03 avatar Jul 04 '25 12:07 Vinzent03