Skip to content

[flutter_migrate] Add ios-language version error handling from flutter 3.35 #9812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

frederikstonge
Copy link

@frederikstonge frederikstonge commented Aug 14, 2025

Since flutter 3.35, flutter_migrate throws an exception because ios-language is being passed as argument and is no longer supported.

Computing migration - this command may take a while to complete.
  Obtaining revisions.
  Parsing unmanagedFiles.
  Generating base reference app.
  Cloning SDK be698c48a6750c8cb8e61c740ca9991bb947aba2
  Creating base app for [android, ios] with revision be698c48a6750c8cb8e61c740ca9991bb947aba2.
  Creating target app with revision b8962555571d8c170cff8e76023ea7bf60e5ec4b.
⣷Unhandled exception:
Error: Command failed with exit code 2: The "ios-language" option is only supported for "--template=plugin".


#0      throwToolExit (package:flutter_migrate/src/base/common.dart:15:3)
#1      MigrateUtils.checkForErrors (package:flutter_migrate/src/utils.dart:313:7)
#2      MigrateUtils.createFromTemplates (package:flutter_migrate/src/utils.dart:175:5)
<asynchronous suspension>
#3      MigrateTargetFlutterProject.createProject (package:flutter_migrate/src/compute.dart:933:7)
<asynchronous suspension>
#4      _generateBaseAndTargetReferenceProjects (package:flutter_migrate/src/compute.dart:456:3)
<asynchronous suspension>
#5      computeMigration (package:flutter_migrate/src/compute.dart:267:7)
<asynchronous suspension>
#6      MigrateStartCommand.runCommand (package:flutter_migrate/src/commands/start.dart:219:42)
<asynchronous suspension>
#7      MigrateCommand.run (package:flutter_migrate/src/base/command.dart:58:5)
<asynchronous suspension>
#8      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#9      main (package:flutter_migrate/executable.dart:56:3)
<asynchronous suspension>
Failed to update packages.

List which issues are fixed by this PR. You must list at least one issue.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above. : I can't see/create issues in this repository.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].

On pub.dev, the published version is already 0.1.0 : https://pub.dev/packages/flutter_migrate

  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1].

There's no test for the other 3 error handling in this method, and there's no ProcessManagerMock to return the desired error from the process.

  • All existing and new tests are passing.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates flutter_migrate to handle an error from newer Flutter versions where the ios-language option is no longer supported for application templates. The changes modify createFromTemplates to make iosLanguage nullable, conditionally add the command-line argument, and recursively retry without it if the specific error is encountered. The package version and changelog have been updated to reflect these changes. My review identifies a critical issue in the implementation of the recursion limit that could lead to infinite loops, and also points out the lack of tests for the new logic.

Comment on lines 138 to 151
// Catch errors due to parameters not supported anymore for apps in flutter 3.35
if (error.contains(
'The "ios-language" option is only supported for "--template=plugin".')) {
return createFromTemplates(
flutterBinPath,
name: name,
legacyNameParameter: legacyNameParameter,
androidLanguage: androidLanguage,
iosLanguage: null,
outputDirectory: outputDirectory,
platforms: platforms,
iterationsAllowed: iterationsAllowed--,
);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This new error handling logic is not covered by any tests. Please consider adding a unit test that mocks ProcessManager to verify that a recursive call with iosLanguage: null is made when this specific error occurs. This will help ensure the logic remains correct in the future.1

Style Guide References

Footnotes

  1. Code should be tested. This change adds new logic that should be covered by tests to ensure correctness and prevent regressions. (link)

@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the state of the PR as posted reflects the checklist please feel free to mark it as ready for review.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft August 14, 2025 20:06
@stuartmorgan-g stuartmorgan-g removed their request for review August 14, 2025 20:06
@frederikstonge frederikstonge force-pushed the features/fred/flutter-3-35 branch from 9a0b103 to a063919 Compare August 14, 2025 23:47
@frederikstonge
Copy link
Author

Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the state of the PR as posted reflects the checklist please feel free to mark it as ready for review.

Thanks for your reply. I have answered a few boxes.

  1. I can't see/create issues in this repository.
  2. On pub.dev, the published version is already 0.1.0 : https://pub.dev/packages/flutter_migrate, which is higher than pubspec and GHANGELOG files.
  3. There's no test for the other 3 error handling in this method, and there's no ProcessManagerMock to return the desired error from the process.

Let me know what you expect from me.

Thank you

@stuartmorgan-g
Copy link
Contributor

  1. I can't see/create issues in this repository.

https://github.com/flutter/packages?tab=readme-ov-file#issues

  1. On pub.dev, the published version is already 0.1.0 : https://pub.dev/packages/flutter_migrate, which is higher than pubspec and GHANGELOG files.

It's not clear how that happened; it appears that at some point someone manually published a version with local modifications, which should not have happened. Those steps can be ignored for now though, as the package is currently marked publish_to: none.

  1. There's no test for the other 3 error handling in this method, and there's no ProcessManagerMock to return the desired error from the process.

Lack of comprehensive tests for existing code doesn't exempt changes from testing; it means that the change has highlighted a testing gap, which should be addressed. See the docs for exemption reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants