{"record":{"id":"b18ca072630e651c","repo":"unslothai/unsloth","slug":"the-pinned-spec-name-archive-ended-unexpectedly","errorCode":null,"errorMessage":"The pinned {spec.name} archive ended unexpectedly","messagePattern":"The pinned (.+?) archive ended unexpectedly","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"studio/backend/utils/third_party_source.py","lineNumber":686,"sourceCode":"                            _package_path_parts(relative, spec, kind = \"archive\")\n                            if relative in extracted:\n                                raise RuntimeError(\n                                    f\"The pinned {spec.name} archive contains duplicate files\"\n                                )\n                            extracted.add(relative)\n                            source_file = bundle.extractfile(member)\n                            if source_file is None:\n                                raise RuntimeError(\n                                    f\"The pinned {spec.name} archive contains an unreadable file\"\n                                )\n                            destination_file = staging.joinpath(*parts[1:])\n                            destination_file.parent.mkdir(parents = True, exist_ok = True)\n                            remaining = member.size\n                            with source_file, destination_file.open(\"wb\") as handle:\n                                while remaining:\n                                    chunk = source_file.read(min(1024 * 1024, remaining))\n                                    if not chunk:\n                                        raise RuntimeError(\n                                            f\"The pinned {spec.name} archive ended unexpectedly\"\n                                        )\n                                    handle.write(chunk)\n                                    remaining -= len(chunk)\n        except (tarfile.TarError, EOFError, OSError) as error:\n            raise RuntimeError(f\"The pinned {spec.name} source archive is invalid\") from error\n        if _sealed_source_manifest(staging, spec) is None:\n            raise RuntimeError(f\"The pinned {spec.name} source archive failed integrity validation\")\n        _replace_owned_directory(staging, destination)\n    finally:\n        _remove_owned_path(workspace)\n\n\ndef _valid_runtime(\n    runtime: Path,\n    spec: PinnedSource,\n    checkout: Path | None = None,\n) -> bool:","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/third_party_source.py#L668-L704","documentation":"While copying a member's content, the reader returned an empty chunk before `remaining` (member.size) reached zero — the tar stream ended mid-file. This is the truncation detector: declared size and actual available bytes disagree, so the archive is incomplete or corrupt.","triggerScenarios":"source_file.read(min(1MiB, remaining)) returns b'' while remaining > 0 — the gzip/tar payload was cut short (truncated download that passed the outer size checks, or a tar whose header size exceeds its data).","commonSituations":"Interrupted or proxy-truncated downloads; gzip streams that decode partially before hitting garbage; archives whose entries lie about size; disk-full during download producing a short file.","solutions":["Re-run the install to force a fresh download into a new temp workspace","Independently verify the artifact: curl the URL, gzip -t it, compare SHA-256 with the pin's expectation","Check destination disk space (archive lands in destination.parent)","If the canonical artifact itself is truncated at the host, pin a different mirror/revision"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import tarfile\nwith tarfile.open(\"source.tar.gz\") as tf:\n    for m in tf:\n        if not m.isdir():\n            f = tf.extractfile(m)\n            got = 0\n            while True:\n                chunk = f.read(1024 * 1024)\n                if not chunk:\n                    break\n                got += len(chunk)\n            assert got == m.size, f\"truncated member {m.name}: {got} != {m.size}\"","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        runtime = ensure_pinned_source(spec)\n        break\n    except RuntimeError as e:\n        if \"ended unexpectedly\" not in str(e) or attempt == 1:\n            raise","preventionTips":["Compare the downloaded tarball's sha256 against the recorded artifact hash before extraction to catch truncation early","Ensure adequate disk space on the cache volume; short writes often trace back to ENOSPC"],"tags":["tarfile","truncated-download","corrupt-archive","extraction"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}