Skip to content

fix: remove trailing carriage return in windows version check#265

Merged
gaby merged 2 commits intogofiber:masterfrom
SamTV12345:feature/windows-support
Feb 4, 2026
Merged

fix: remove trailing carriage return in windows version check#265
gaby merged 2 commits intogofiber:masterfrom
SamTV12345:feature/windows-support

Conversation

@SamTV12345
Copy link
Copy Markdown
Contributor

@SamTV12345 SamTV12345 commented Feb 3, 2026

Pull Request Guide

When I first checked out the migration tool I was wondering why such a tool breaks at first try. I then digged deeper and realized that Windows is the problem returning the version with a \r at the end which the semver parser declines. This is now fixed with a trimSpace. See the stacktrace below:

(0x7ff7a3ba3520,0x7ff7a4131920)
panic: invalid semantic version

goroutine 1 [running]:
github.com/Masterminds/semver/v3.MustParse(...)
        C:/Users/samue/go/pkg/mod/github.com/!masterminds/semver/v3@v3.4.0/version.go:312
github.com/gofiber/cli/cmd.migrateRunE(0xc0001cd508, {{0x7ff7a3a558cd, 0x6}, {0x0, 0x0}, {0x0, 0x0}, {0x7ff7a41a7800, 0x0, 0x0}, ...})
        C:/Users/samue/go/pkg/mod/github.com/gofiber/cli@v0.11.2/cmd/migrate.go:101 +0xdab
github.com/gofiber/cli/cmd.newMigrateCmd.func1(0xc0001cd508, {0x7ff7a3a53937?, 0x4?, 0x7ff7a3a5393b?})
        C:/Users/samue/go/pkg/mod/github.com/gofiber/cli@v0.11.2/cmd/migrate.go:60 +0x385
github.com/spf13/cobra.(*Command).execute(0xc0001cd508, {0xc000125540, 0x1, 0x1})
        C:/Users/samue/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0x7ff7a4150100)
        C:/Users/samue/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        C:/Users/samue/go/pkg/mod/github.com/spf13/cobra@v1.10.2/command.go:1071
github.com/gofiber/cli/cmd.Execute()
        C:/Users/samue/go/pkg/mod/github.com/gofiber/cli@v0.11.2/cmd/root.go:95 +0x1a
main.main()
        C:/Users/samue/go/pkg/mod/github.com/gofiber/cli@v0.11.2/fiber/main.go:8 +0xf

Please provide enough information so that others can review your pull request:

Explain the details for making this change. What existing problem does the pull request solve?

Commit formatting

Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me

Summary by CodeRabbit

  • Bug Fixes

    • Version strings now display without extraneous whitespace for cleaner formatting.
    • Version parsing now correctly handles files with Windows CRLF line endings.
  • Tests

    • Added a test verifying version extraction works for CRLF-formatted version files.

@SamTV12345 SamTV12345 requested a review from a team as a code owner February 3, 2026 20:31
@SamTV12345 SamTV12345 requested review from ReneWerner87, efectn, gaby and sixcolors and removed request for a team February 3, 2026 20:31
@ReneWerner87 ReneWerner87 added ☢️ Bug Something isn't working 🧹 Updates labels Feb 3, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @SamTV12345, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug impacting the migration tool's functionality on Windows. The core problem stemmed from the semver parser's inability to handle version strings that included a trailing carriage return, a common occurrence on Windows systems. By implementing a simple yet effective whitespace trimming operation during version extraction, this change ensures consistent and robust version parsing across different operating systems, thereby preventing application crashes and improving overall cross-platform compatibility.

Highlights

  • Windows Compatibility Fix: Resolves an issue where the semver parser would fail on Windows due to a trailing carriage return (\r) in the extracted version string, causing the migration tool to panic.
  • Robust Version Parsing: Enhances the version extraction logic by applying strings.TrimSpace() to the retrieved version string, ensuring that leading or trailing whitespace characters, including carriage returns, are removed before semantic version parsing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/version.go
    • Modified the currentVersionFromFile function to use strings.TrimSpace() on the extracted version string before returning it. This removes any leading or trailing whitespace, including carriage returns, which previously caused semver parsing errors on Windows.
Activity
  • The pull request was created by SamTV12345 to fix a panic caused by invalid semantic version parsing on Windows.
  • The author provided a detailed description including a stack trace demonstrating the issue.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@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 correctly fixes a crash that occurs on Windows when checking the version. The issue was caused by a carriage return being part of the version string, which is now properly handled by using strings.TrimSpace. The fix is effective. I've added a suggestion to include a new test case to cover this specific scenario and prevent future regressions. Overall, this is a good contribution.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 3, 2026

Walkthrough

The file-reading function currentVersionFromFile (cmd/version.go) now trims leading and trailing whitespace from the captured version string. A new test verifies parsing of a CRLF-terminated version file (cmd/version_test.go).

Changes

Cohort / File(s) Summary
Version parsing
cmd/version.go
Return value from currentVersionFromFile is now strings.TrimSpace-ed to remove surrounding whitespace.
Tests (CRLF handling)
cmd/version_test.go
Added test "can read version from windows clrf file" to ensure currentVersion correctly reads versions from CRLF-terminated files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibbled at whitespace, neat and small,
Trimmed the edges, answered the call.
CRLF or LF, the version's now true,
Hops of joy for a tidy view! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the problem (Windows CRLF causes semver parser to fail), provides a stack trace demonstrating the issue, and describes the fix (trimSpace). However, it includes boilerplate template text and lacks explicit explanation of why trimming solves the problem.
Title check ✅ Passed The title clearly identifies the specific issue being fixed: removing trailing carriage returns in the Windows version check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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

🤖 Fix all issues with AI agents
In `@cmd/version_test.go`:
- Around line 101-105: Rename the test case from "can read version from windows
clrf file" to "can read version from windows crlf file" and fix the fixture in
the content variable by removing the stray '\r' that appears between the module
path and version (the sequence `"\tgithub.com/gofiber/fiber\r v0.0.0-..."`),
ensuring lines use proper CRLF pairs like `"\r\n"` only; update the t.Run name
and the content string in the test function so the fixture accurately represents
real Windows CRLF line endings.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfff1bd and d6bc45f.

📒 Files selected for processing (1)
  • cmd/version_test.go

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@SamTV12345
Copy link
Copy Markdown
Contributor Author

Sorry AI. This is actually by design lol.

@gaby gaby changed the title fix: remove trailing cariage return in windows version check fix: remove trailing carriage return in windows version check Feb 4, 2026
@gaby gaby merged commit fce83cd into gofiber:master Feb 4, 2026
15 checks passed
@welcome
Copy link
Copy Markdown

welcome bot commented Feb 4, 2026

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@gaby
Copy link
Copy Markdown
Member

gaby commented Feb 4, 2026

@SamTV12345 Thank you, tagged. https://github.com/gofiber/cli/releases/tag/v0.11.3

@SamTV12345
Copy link
Copy Markdown
Contributor Author

You're welcome!

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

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants