fix: detect Unity 6 projects (6000.M.PPl# version scheme) - #250
Merged
Conversation
Reported on Discord: engine auto-detection ("Unity project detection
failed") for Unity 6 projects. Traced to
UnityVersionDetector.versionPattern - the exact class this is,
UnityVersionDetector#versionPattern, was named directly in the report.
The old pattern was /20\d{2}\.\d\.\w{3,4}|3/, which had two separate
bugs:
- `20\d{2}` only matches the legacy YYYY-scheme major version. Unity
6's "6000.M.PPl#" scheme (e.g. "6000.0.78f1") starts with "6000", not
"20xx", so it never matched at all.
- The trailing `|3` alternation - regex alternation has very low
precedence - made the whole pattern effectively
`(20\d{2}\.\d\.\w{3,4})|(3)`. Once the first branch failed to match
(as it always did for Unity 6), `.match()` fell through to matching a
bare literal "3" anywhere in the file - which the "6000.0.78f1" string
itself contains. So this wasn't just "detection failed": a real Unity
6 project silently "detected" as version "3", which would have gone
on to build a nonsense Docker image tag with zero indication of the
real cause. Confirmed both failure modes by running the exact
pre-fix code against real ProjectVersion.txt content.
This is the actual engine auto-detection entry point
(UnityVersionDetector.isUnityProject/getUnityVersion, called from
unity-plugin.ts) - not a secondary path - so every Unity 6 user running
plain `game-ci build` without an explicit --engine override was
affected.
Fix: anchor extraction to Unity's own `m_EditorVersion: <version>` key
instead of a floating version-shaped substring search. `\d+` (not a
fixed `20\d{2}`) covers both the legacy and Unity 6 schemes - the same
fix RunnerImageTag.versionPattern already carries for a different
caller (validating an explicit --engineVersion override rather than
parsing ProjectVersion.txt; see #154, game-ci/unity-builder#847).
Existing test coverage was minimal (2 tests, neither exercising Unity
6 - which is exactly how this shipped unnoticed) and preserved here
alongside new coverage for: the Unity 6 scheme, the
m_EditorVersionWithRevision line not being mistaken for
m_EditorVersion, the old bug's bare-"3" false positive not recurring,
and the real isUnityProject/getUnityVersion path end-to-end against an
actual ProjectVersion.txt fixture already in this repo.
Verified: tsc --noEmit clean; new test file 9/9 pass; full `bun test
./src` shows the same 2 pre-existing failures (an unrelated
`form-data` module resolution issue) as clean main, confirmed by
diffing against a stash of this fix - no regressions.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 54 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported on Discord: engine auto-detection ("Unity project detection failed") for Unity 6 projects, even on v0.1.51. The report named the exact spot - `UnityVersionDetector#versionPattern` - and it was right.
Root cause
`versionPattern` was `/20\d{2}.\d.\w{3,4}|3/`, which had two separate bugs:
So this wasn't just "detection failed": a real Unity 6 project silently "detected" as version `"3"", which would have gone on to build a nonsense Docker image tag with zero indication of the real cause. Reproduced both failure modes by running the exact pre-fix code against real `ProjectVersion.txt` content:
```
OLD CODE result for Unity 6: "3"
```
This is the actual engine auto-detection entry point (`UnityVersionDetector.isUnityProject`/`getUnityVersion`, called from `unity-plugin.ts`) - not a secondary path - so every Unity 6 user running plain `game-ci build` without an explicit `--engine` override was affected.
Fix
Anchor extraction to Unity's own `m_EditorVersion: ` key instead of a floating version-shaped substring search. `\d+` (not a fixed `20\d{2}`) covers both the legacy and Unity 6 schemes - the same fix `RunnerImageTag.versionPattern` already carries for a different caller (validating an explicit `--engineVersion` override rather than parsing `ProjectVersion.txt`; see #154, unity-builder#847).
Test coverage
Existing coverage was minimal (2 tests, neither exercising Unity 6 - exactly how this shipped unnoticed) and is preserved here, plus new coverage for: the Unity 6 scheme, `m_EditorVersionWithRevision` not being mistaken for `m_EditorVersion`, the old bug's bare-`"3"` false positive not recurring, and the real `isUnityProject`/`getUnityVersion` path end-to-end against an actual `ProjectVersion.txt` fixture already in this repo.
Verification
Co-Authored-By: Claude Opus 5 noreply@anthropic.com