mastodon-dart / mastodon-api

This library provides the easiest and powerful Dart/Flutter library for Mastodon API 🎯
http://pub.dev/packages/mastodon_api
BSD 3-Clause "New" or "Revised" License
64 stars 13 forks source link

Bug Report: #158

Open aramter opened 11 months ago

aramter commented 11 months ago

1. Current bug behavior

when sending Local from Flutter App for example (en_US) to open an account We get error ✅ Body: {"error":"Validation failed: Locale is not included in the list","details":{"locale":[{"error":"ERR_INCLUSION","description":"is not included in the list"}]}}

2. Expected behavior

Should open the account, we have 'en' as default in Mastodon server we tried to use 'en_US' in env file, still getting the same error.

3. Steps to reproduce

Call create account with any local en, en_US de, de_De ... - still getting the error

4. Flutter doctor output

Flutter outpu I/flutter (15297): Country.unitedStates I/flutter (15297): Language.english I/flutter (15297): en_US [log] An error occurred: MastodonException: Required parameter is missing or improperly formatted.

✅ Status Code: 422

✅ Request: POST https://mastodon-dev.connectto.com/api/v1/accounts?

✅ Headers: {connection: keep-alive, cache-control: private, no-store, transfer-encoding: chunked, date: Thu, 26 Oct 2023 21:40:26 GMT, x-ratelimit-limit: 5, x-ratelimit-reset: 2023-10-26T22:00:00.122426Z, vary: Authorization, Origin, strict-transport-security: max-age=63072000; includeSubDomains, referrer-policy: same-origin, x-ratelimit-remaining: 4, content-type: application/json; charset=utf-8, x-xss-protection: 0, server: Mastodon, x-request-id: cfde03da-4b9b-4bf5-9a98-86781f3d3bb1, x-runtime: 0.288634, x-frame-options: DENY, x-content-type-options: nosniff, content-security-policy: default-src 'none'; frame-ancestors 'none'; form-action 'none'}

✅ Body: {"error":"Validation failed: Locale is not included in the list","details":{"locale":[{"error":"ERR_INCLUSION","description":"is not included in the list"}]}}

Please create an Issue if you have a question or suggestion for this exception. https://github.com/mastodon-dart/mastodon-api/issues

Output of: flutter doctor -v

√] Flutter (Channel beta, 3.16.0-0.3.pre, on Microsoft Windows [Version 10.0.19041.630], locale en-US)
    • Flutter version 3.16.0-0.3.pre on channel beta at C:\xxx\projects\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 476aa717cd (7 days ago), 2023-10-19 20:10:52 -0500
    • Engine revision 91cde06da0
    • Dart version 3.2.0 (build 3.2.0-210.3.beta)
    • DevTools version 2.28.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\xxx\AppData\Local\Android\Sdk
    • Platform android-33, build-tools 34.0.0
    • ANDROID_HOME = C:\Users\xxx\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio4\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.7.34031.279
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio4
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[√] IntelliJ IDEA Ultimate Edition (version 2018.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2018.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] IntelliJ IDEA Ultimate Edition (version 2021.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2
    • Flutter plugin version 63.2.4
    • Dart plugin version 213.5744.122

[√] VS Code (version 1.75.1)
    • VS Code at C:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.64.0

[√] Connected device (4 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 8.0.0 (API 26) (emulator)
    • Windows (desktop)                  • windows       • windows-x64    • Microsoft Windows [Version 10.0.19041.630]
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 118.0.5993.90
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 118.0.2088.46

[√] Network resources
    • All expected network resources are available.

• No issues found!
PS C:\Users\xxx> 

5. More environment information

6. Log information

I/flutter (15297): Country.unitedStates I/flutter (15297): Language.english I/flutter (15297): en_US [log] An error occurred: MastodonException: Required parameter is missing or improperly formatted.

✅ Status Code: 422

✅ Request: POST https://mastodon-dev.connectto.com/api/v1/accounts?

✅ Headers: {connection: keep-alive, cache-control: private, no-store, transfer-encoding: chunked, date: Thu, 26 Oct 2023 21:40:26 GMT, x-ratelimit-limit: 5, x-ratelimit-reset: 2023-10-26T22:00:00.122426Z, vary: Authorization, Origin, strict-transport-security: max-age=63072000; includeSubDomains, referrer-policy: same-origin, x-ratelimit-remaining: 4, content-type: application/json; charset=utf-8, x-xss-protection: 0, server: Mastodon, x-request-id: cfde03da-4b9b-4bf5-9a98-86781f3d3bb1, x-runtime: 0.288634, x-frame-options: DENY, x-content-type-options: nosniff, content-security-policy: default-src 'none'; frame-ancestors 'none'; form-action 'none'}

✅ Body: {"error":"Validation failed: Locale is not included in the list","details":{"locale":[{"error":"ERR_INCLUSION","description":"is not included in the list"}]}}

Please create an Issue if you have a question or suggestion for this exception. https://github.com/mastodon-dart/mastodon-api/issues



# 7. More information

We have DEFAULT_LOCALE en in env file  - we tried other languages, but getting errors, we even tried en_US same error
github-actions[bot] commented 11 months ago

Thanks for your contribution! :)

aramter commented 11 months ago

This is how the Locale is created Locale locale = const Locale(lang: Language.english, country: Country.unitedStates);

This is the function

Future createMastodonAccount({ required String username, required String email, required String password, required bool agreement, required Locale locale, String? reason, }) async { try { final response = await mastodon!.v1.accounts.createAccount( username: username, email: email, password: password, agreement: agreement, locale: locale, reason: reason, );

if (response.status.code == 200) {
  if (kDebugMode) {
    print("Account created successfully");
    log("Token Data: ${response.data}");
    print("Failed to create account");
  }
}

} catch (e) { if (kDebugMode) { print(locale.country.toString());

  print(locale.lang.toString());

  print(locale.toString());

  log("An error occurred: $e");
}

} }

And this is how it is called await createMastodonAccount(username: 'xxxxr', email: 'xxxx@gmail.com', agreement: true, password: 'xxxx',locale: locale, reason: 'xxxxx');