{"record":{"id":"f21bf1ac9e9e2a61","repo":"XX-net/XX-Net","slug":"get-version-fail-in-update-from-github","errorCode":null,"errorMessage":"get_version_fail in update_from_github","messagePattern":"get_version_fail in update_from_github","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/launcher/update_from_github.py","lineNumber":191,"sourceCode":"                    return versions\n    except Exception as e:\n        xlog.exception(\"xxnet_version fail:%r\", e)\n\n    raise Exception(\"get_version_fail:%s\" % readme_file)\n\n\ndef current_version():\n    readme_file = os.path.join(root_path, \"version.txt\")\n    try:\n        with open(readme_file) as fd:\n            content = fd.read()\n            p = re.compile(r'([0-9]+)\\.([0-9]+)\\.([0-9]+)')\n            m = p.match(content)\n            if m:\n                version = m.group(1) + \".\" + m.group(2) + \".\" + m.group(3)\n                return version\n    except:\n        xlog.warn(\"get_version_fail in update_from_github\")\n\n    return \"get_version_fail\"\n\n\ndef get_github_versions():\n    readme_url = \"https://raw.githubusercontent.com/XX-net/XX-Net/master/code/default/update_v5.txt\"\n    readme_target = os.path.join(download_path, \"version.txt\")\n\n    if not download_file(readme_url, readme_target):\n        raise IOError(\"get update file %s fail:\" % readme_url)\n\n    versions = parse_update_versions(readme_target)\n    return versions\n\n\ndef get_hash_sum(version):\n    versions = get_github_versions()\n    for v in versions:","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/launcher/update_from_github.py#L173-L209","documentation":"current_version() reads version.txt (local or GitHub) and regex-matches an x.y.z pattern; on any read failure or non-match it logs this warning and returns the sentinel string 'get_version_fail'. Callers comparing versions must handle this sentinel.","triggerScenarios":"version.txt missing/unreadable, network failure fetching the GitHub version file, or content not matching ([0-9]+)\\.([0-9]+)\\.([0-9]+) at the string start.","commonSituations":"First run without version.txt; offline machine; GitHub blocked; version file format changed (e.g. leading 'v' or extra text before the numbers).","solutions":["Check that code/default/update_v5.txt / local version.txt exists and starts with a dotted triplet like 3.13.2.","Fix network/GitHub access so the version file can be fetched.","Treat the returned 'get_version_fail' string as a failure in callers instead of comparing it as a version.","Loosen/anchor the regex if the upstream format changed."],"exampleFix":"// before\nm = re.compile(r'([0-9]+)\\.([0-9]+)\\.([0-9]+)').match(content)\n// after\nm = re.compile(r'v?(\\d+)\\.(\\d+)\\.(\\d+)').search(content)","handlingStrategy":"fallback","validationCode":"v = current_version()\nif v == 'get_version_fail' or not re.match(r'\\d+\\.\\d+\\.\\d+$', v):\n    raise RuntimeError('cannot determine current version')","typeGuard":"def is_version(s):\n    return bool(re.match(r'^\\d+\\.\\d+\\.\\d+$', s or ''))","tryCatchPattern":null,"preventionTips":["Never compare 'get_version_fail' against version tuples.","Keep version.txt present and readable.","Test GitHub reachability before update flows."],"tags":["version","parsing","update","network"],"backgroundTag":"version-parse-failed","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}