Skip to content

[gen-l10n] Failed to complete the generation when FLUTTER_STORAGE_BASE_URL is overridden #119593

@AlexV525

Description

@AlexV525

The issue is breaking every user that is using localizations and a custom FLUTTER_STORAGE_BASE_URL.

This also happens with flutter pub get if the l10n generation is synthetic.

C 2GWA62)A7VKK 59JJ3%31

The tool will report Found syntax errors but not any actual syntax errors.

Related issues:

Root cause

When FLUTTER_STORAGE_BASE_URL is being overridden, the cache getter will try to raise an error to STDERR that the user is using a custom storage base.

_logger.printError(
'Flutter assets will be downloaded from $overrideUrl. Make sure you trust this source!',
emphasis: true,
);

But using an error print will cause the generate tool recognized as an exception.

// If there were any syntax errors, don't write to files.
if (logger.hadErrorOutput) {
throw L10nException('Found syntax errors.');
}

And when it's using synthetic package, flutter pub get will also raise exceptions.

if (result.hasException) {
throwToolExit(
'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:'
'\n\n'
'${result.exceptions.values.map<Object?>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
);
}

Steps to Reproduce

  1. Run export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn in the terminal.
  2. flutter create test_l10n
  3. Setup internationalization for the project according to the doc.
  4. flutter pub get or flutter gen-l10n

flutter doctor -v

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!

[!] Flutter (Channel stable, 3.7.0, on Microsoft Windows [版本 10.0.22000.1455], locale zh-CN)
    • Flutter version 3.7.0 on channel stable at X:\SDK\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (7 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: internationalizationSupporting other languages or locales. (aka i18n)c: regressionIt was better in the past than it is nowtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions