Skip to content

fix: version parsing failure on nightly tags#2249

Merged
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:update-checker
Jun 16, 2026
Merged

fix: version parsing failure on nightly tags#2249
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:update-checker

Conversation

@AuDevTist1C

@AuDevTist1C AuDevTist1C commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Refactors the update-checking logic to use regular expression matching instead of basic string replacement when parsing version tags.

Previously, passing a nightly string like "1.12.5-nightly.xxxx" through .replace("v", "").split(".") resulted in non-numeric array elements (e.g., "5-nightly"), which evaluated to NaN and broke downstream version comparison checks.

Changes implemented:

  • Replaced string replacement with .match(/^v?(\d+(?:\.\d+)*)/)?.[1] to cleanly isolate the leading numeric SemVer elements.
  • Applied matching symmetrically across both release.tag_name and BuildInfo.version arrays to guarantee structural parsing alignment.

(PR name and description are AI generated)

@bajrangCoder bajrangCoder changed the title fix: Fix version parsing failure on nightly tags fix: version parsing failure on nightly tags Jun 15, 2026
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes version parsing for nightly release tags (e.g. "1.12.5-nightly.xxxx") by switching from .replace("v", "").split(".") to a regex match that extracts only the leading numeric semver segment. A null-guard and error log were also added to handle malformed version strings.

  • The regex approach correctly strips pre-release suffixes before splitting, fixing the NaN comparison bug for nightly builds.
  • The added null-guard (if (!(latestVersion && currentVersion))) is unreachable in the failure case: when match() returns null, the optional chain yields undefined, but the immediately-chained .split(".") call on that undefined throws a TypeError before the variable assignment completes — so the guard is never evaluated.

Confidence Score: 4/5

The core nightly-tag fix is correct, but the defensive null-guard added alongside it is unreachable in the exact failure scenario it was designed to handle.

The regex replacement correctly resolves the NaN comparison bug for nightly tags. However, the guard that was added to handle malformed version strings from the GitHub API is never reached when match() returns null — the .split('.') call on undefined throws before the assignment completes, bypassing the guard entirely. The update-check path would still crash silently on an unexpected tag format.

src/main.js — specifically the null-guard placement relative to the optional-chain and .split() call in the version parsing block.

Important Files Changed

Filename Overview
src/main.js Refactors version string parsing to use a regex instead of simple string replacement, fixing NaN comparisons for nightly tags. A null-guard was added but is unreachable — the .split() call on the optionally-chained result can still throw before the guard is evaluated.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[GitHub API response] --> B[release.tag_name]
    B --> C["match regex"]
    C -- match found --> D["group 1 e.g. '1.12.5'"]
    C -- no match --> E["optional chain returns undefined"]
    D --> F["split('.') to array"]
    E --> G["split on undefined throws TypeError"]
    G --> H["Guard is never reached"]
    F --> I["map to Number"]
    I --> J[latestVersion]
    K[BuildInfo.version] --> L["match regex"]
    L -- match found --> M["group 1 e.g. '1.12.5'"]
    L -- no match --> N["optional chain returns undefined"]
    M --> O["split and map to Number"]
    N --> P["split on undefined throws TypeError"]
    O --> Q[currentVersion]
    J --> R{"Guard check: latestVersion and currentVersion"}
    Q --> R
    R -- false --> S["log error and return"]
    R -- true --> T[Version comparison loop]
    T --> U{hasUpdate?}
    U -- yes --> V[Push update notification]
    U -- no --> W[No notification]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[GitHub API response] --> B[release.tag_name]
    B --> C["match regex"]
    C -- match found --> D["group 1 e.g. '1.12.5'"]
    C -- no match --> E["optional chain returns undefined"]
    D --> F["split('.') to array"]
    E --> G["split on undefined throws TypeError"]
    G --> H["Guard is never reached"]
    F --> I["map to Number"]
    I --> J[latestVersion]
    K[BuildInfo.version] --> L["match regex"]
    L -- match found --> M["group 1 e.g. '1.12.5'"]
    L -- no match --> N["optional chain returns undefined"]
    M --> O["split and map to Number"]
    N --> P["split on undefined throws TypeError"]
    O --> Q[currentVersion]
    J --> R{"Guard check: latestVersion and currentVersion"}
    Q --> R
    R -- false --> S["log error and return"]
    R -- true --> T[Version comparison loop]
    T --> U{hasUpdate?}
    U -- yes --> V[Push update notification]
    U -- no --> W[No notification]
Loading

Reviews (4): Last reviewed commit: "fix(updater): version parsing failure on..." | Re-trigger Greptile

Comment thread src/main.js Outdated
Refactors the update-checking logic to use regular expression matching
instead of basic string replacement when parsing version tags.

Previously, passing a nightly string like "1.12.5-nightly.xxxx" through
`.replace("v", "").split(".")` resulted in non-numeric array elements
(e.g., "5-nightly"), which evaluated to `NaN` and broke downstream version
comparison checks.

Changes implemented:
* Replaced string replacement with `.match(/^v?(\d+(?:\.\d+)*)/)[1]` to cleanly
  isolate the leading numeric SemVer elements.
* Applied matching symmetrically across both `release.tag_name` and
  `BuildInfo.version` arrays to guarantee structural parsing alignment.

(AI generated commit message)
@AuDevTist1C AuDevTist1C force-pushed the update-checker branch 2 times, most recently from 3aec1e8 to 7a63f1d Compare June 16, 2026 06:38
Comment thread src/main.js
@bajrangCoder bajrangCoder merged commit b60de55 into Acode-Foundation:main Jun 16, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jun 16, 2026
@AuDevTist1C AuDevTist1C deleted the update-checker branch June 16, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants