Skip to content
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

fix: Fix FormatException caused by '@' in Custom Flutter Version #808

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

franticn
Copy link

@franticn franticn commented Dec 23, 2024

As described in the documentation on https://fvm.app/documentation/advanced/custom-version, when we want to manage a custom version of the Flutter SDK in FVM, we need to use custom_ as a prefix for the version. However, it does not support naming conventions that include an @ symbol, such as custom_3.7.0@huawei. This is because previously, the FlutterVersion#parse(String version) method would first attempt to parse a FlutterVersion.release type of FlutterVersion, and would split the string at the @ symbol. This would cause parsing errors for custom version numbers like custom_3.7.0@huawei. Therefore, I have prioritized the parsing of FlutterVersion.custom to ensure that such FlutterVersion can be successfully parsed.

Summary by CodeRabbit

  • New Features

    • Added support for custom Flutter version handling
    • Updated Flutter release information for Linux, macOS, and Windows platforms
  • Bug Fixes

    • Improved version parsing logic for custom Flutter versions
  • Documentation

    • Enhanced test coverage for version model and custom version scenarios

Copy link

vercel bot commented Dec 23, 2024

@franticn is attempting to deploy a commit to the FlutterTools Team on Vercel.

A member of the Team first needs to authorize it.

{
  "date": "2025-01-13T23:01:03.050Z",
  "files": [
    {
      "name": "releases_macos.json",
      "deltaBytes": 790,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json"
    },
    {
      "name": "releases_windows.json",
      "deltaBytes": 395,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_windows.json"
    },
    {
      "name": "releases_linux.json",
      "deltaBytes": 394,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json"
    }
  ]
}
{
  "date": "2025-01-21T21:01:00.965Z",
  "files": [
    {
      "name": "releases_macos.json",
      "deltaBytes": 790,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json"
    },
    {
      "name": "releases_windows.json",
      "deltaBytes": 395,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_windows.json"
    },
    {
      "name": "releases_linux.json",
      "deltaBytes": 394,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json"
    }
  ]
}
{
  "date": "2025-01-27T21:00:59.751Z",
  "files": [
    {
      "name": "releases_macos.json",
      "deltaBytes": 860,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json"
    },
    {
      "name": "releases_windows.json",
      "deltaBytes": 430,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_windows.json"
    },
    {
      "name": "releases_linux.json",
      "deltaBytes": 429,
      "source": "https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json"
    }
  ]
}
Copy link

coderabbitai bot commented Jan 27, 2025

Walkthrough

The pull request introduces updates to Flutter version management across multiple platforms. The changes primarily involve modifying the FlutterVersion model's parsing logic for custom versions and updating release information for Linux, macOS, and Windows platforms. The modifications include adjusting the version parsing method, adding new release entries, and expanding test coverage for custom version handling.

Changes

File Change Summary
lib/src/models/flutter_version_model.dart Rearranged custom version parsing logic, moving the custom version check to the beginning of the parse method
releases_linux.json Updated current_release with new beta and stable versions, added new release entries for versions 3.29.0-0.2.pre and 3.27.3
releases_macos.json Updated current_release, added new beta and stable release entries for versions 3.29.0-0.2.pre, 3.27.3, and 3.27.2
releases_windows.json Updated current release hashes for beta and stable channels, added new release entries for versions 3.29.0-0.2.pre, 3.27.3, and 3.27.2
test/models/flutter_version_model_test.dart Added new test cases for custom version handling, including tests for the custom constructor, parse method, and isCustom getter

Sequence Diagram

sequenceDiagram
    participant Parser as FlutterVersion.parse()
    participant Version as FlutterVersion

    alt Custom Version
        Parser ->> Parser: Check for 'custom_' prefix
        Parser ->> Version: Create custom version
    else Standard Version
        Parser ->> Parser: Split version string
        Parser ->> Version: Create standard version
    end
Loading

Poem

🐰 A Flutter version tale, oh so bright,
Custom parsing now takes first flight!
Linux, Mac, and Windows in sync,
Releases dancing with each new link 🔗
Version magic, rabbit's delight! 🚀


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/src/models/flutter_version_model.dart (1)

61-64: LGTM! Consider adding documentation for custom version handling.

The change correctly fixes the FormatException by checking for custom versions before splitting on '@'. This ensures custom versions like 'custom_3.7.0@huawei' are handled properly.

Consider adding a code comment explaining that custom versions are handled as-is without parsing to prevent '@' symbol issues:

 factory FlutterVersion.parse(String version) {
-    // Check if its custom.
+    // Handle custom versions first and preserve their full name without parsing
+    // to support version strings containing '@' (e.g., custom_3.7.0@huawei)
     if (version.startsWith('custom_')) {
       return FlutterVersion.custom(version);
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da13926 and a06d750.

📒 Files selected for processing (5)
  • lib/src/models/flutter_version_model.dart (1 hunks)
  • releases_linux.json (1 hunks)
  • releases_macos.json (2 hunks)
  • releases_windows.json (1 hunks)
  • test/models/flutter_version_model_test.dart (3 hunks)
🔇 Additional comments (10)
test/models/flutter_version_model_test.dart (3)

83-88: LGTM! Good test coverage for custom constructor.

The test verifies that the custom constructor correctly handles version strings containing '@' symbols.


119-124: LGTM! Good test coverage for parse method.

The test verifies that the parse method correctly identifies and preserves custom version strings containing '@' symbols.


179-182: LGTM! Good test coverage for isCustom getter.

The test verifies that isCustom correctly identifies custom versions containing '@' symbols.

releases_linux.json (3)

15-15: Verify the release dates in the new entries

The release dates for both new entries are set in 2025:

  • Line 15: "2025-01-27T20:27:45.101671Z"
  • Line 25: "2025-01-21T20:35:29.161615Z"

These future dates seem incorrect and should be reviewed.

Also applies to: 25-25


9-18: LGTM! Release entries follow the standard format

The new release entries contain all required fields and follow the consistent format:

  • hash
  • channel
  • version
  • dart_sdk_version
  • dart_sdk_arch
  • release_date
  • archive
  • sha256

Also applies to: 19-28


4-4: LGTM! Current release hashes updated correctly

The current_release section is properly updated with new hashes pointing to the latest releases for beta and stable channels.

Also applies to: 6-6

releases_windows.json (2)

4-6: LGTM! Current release updates look good.

The updates to current_release section are consistent with the latest beta and stable versions.


9-38: LGTM! New release entries are properly formatted.

The new release entries for versions 3.29.0-0.2.pre, 3.27.3, and 3.27.2 contain all required fields and follow the established schema.

Note: While these changes appear correct, they seem unrelated to the PR's objective of fixing FormatException for custom Flutter versions with '@' symbols. Could you clarify how these version updates help address the reported issue?

releases_macos.json (2)

4-4: Version references in current_release are consistent

The current_release section correctly references the latest beta (3.29.0-0.2.pre) and stable (3.27.3) versions that match with their corresponding release entries.

Also applies to: 6-6


314-314: Formatting improvements in existing entries

The changes to existing release entries improve readability through consistent indentation and line breaks.

Also applies to: 316-317, 324-324, 326-327

"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:19:00.875075Z",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Release dates are set in the future

The release dates for new entries are set in 2025, which is beyond the current date. This could cause issues with release management and version comparisons.

Update the release dates to use the correct current or past dates. For example:

-      "release_date": "2025-01-27T20:19:00.875075Z",
+      "release_date": "2024-01-27T20:19:00.875075Z"

Also applies to: 25-25, 35-35, 45-45, 55-55, 65-65

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.

2 participants