{"record":{"id":"4dda80e66b9ce121","repo":"unslothai/unsloth","slug":"virustotal-request-failed-after-max-attempts-att","errorCode":null,"errorMessage":"VirusTotal request failed after {max_attempts} attempt(s): {last_error}","messagePattern":"VirusTotal request failed after (.+?) attempt\\(s\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"scripts/virustotal_scan.py","lineNumber":441,"sourceCode":"                if attempt < max_attempts:\n                    self._backoff(backoff * (2 ** (attempt - 1)), deadline)\n                continue\n            if status == 0 or status >= 500:\n                last_error = last_error or f\"HTTP {status}\"\n                if attempt < max_attempts:\n                    self._backoff(backoff * (2 ** (attempt - 1)), deadline)\n                continue\n            if status >= 400 and status not in allow_status:\n                raise RuntimeError(f\"VirusTotal returned HTTP {status} for {_redact_url(url)}\")\n\n            if not payload:\n                return status, None\n            try:\n                return status, json.loads(payload.decode(\"utf-8\", \"replace\"))\n            except json.JSONDecodeError:\n                return status, None\n\n        raise RuntimeError(\n            f\"VirusTotal request failed after {max_attempts} attempt(s): {last_error}\"\n        )\n\n    def lookup_hash(\n        self,\n        sha256: str,\n        deadline: float | None = None,\n    ) -> object | None:\n        \"\"\"Return the existing file report, or None when VirusTotal has never seen it.\n\n        Doing this first is both a quota saving and a disclosure saving: a bundle that\n        VirusTotal already holds gains nothing from being uploaded again.\n        \"\"\"\n        status, payload = self.request(\n            \"GET\",\n            f\"{API_ROOT}/files/{sha256}\",\n            allow_status = (404,),\n            deadline = deadline,","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/scripts/virustotal_scan.py#L423-L459","documentation":"Thrown by use-chat-model-runtime.ts:1142-1144 via getTrustRemoteCodeRequiredMessage (line 276-278) when validateModel flags requires_trust_remote_code or requires_security_review and the user does not complete the remote-code consent dialog — confirmRemoteCodeIfNeeded resolved approved=false. Models with custom modeling code (trust_remote_code) require an explicit review/approval that records a fingerprint; without approval the worker refuses the load. The dialog fires even when trustRemoteCode is preset, because the worker needs the matching fingerprint only the dialog produces.","triggerScenarios":"Loading a Hub model with custom code (or a flagged unsafe file) where validation sets requires_trust_remote_code / requires_security_review, and the user cancels the code-review dialog or rejects the code after reviewing it.","commonSituations":"Newer/niche architectures not yet in the installed transformers (Phi-style custom models); users wary of remote code; the security review flagging a file in the repo; dialog dismissed with Escape.","solutions":["Load the model again, open the review dialog, read the custom code, and approve it — the recorded fingerprint lets the load proceed.","If the code looks unsafe, do not approve: choose a different model or a transformers-native/GGUF variant that needs no custom code.","Keep the studio backend updated so more architectures are natively supported and the consent gate disappears for them."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async function needsRemoteCodeConsent(modelId: string): Promise<boolean> {\n  const v = await validateModel({ model_path: modelId });\n  return Boolean(v.requires_trust_remote_code || v.requires_security_review);\n}","typeGuard":"function isRemoteCodeApprovalError(e: unknown): e is Error {\n  return e instanceof Error && /custom code was not approved/.test(e.message);\n}","tryCatchPattern":"try {\n  await loadModel(selection);\n} catch (error) {\n  if (isRemoteCodeApprovalError(error)) {\n    // safe to retry: re-run load, complete the review dialog, approve\n  } else throw error;\n}","preventionTips":["Approve the code-review dialog only after actually reading the custom modeling files.","Cache the approval fingerprint so repeat loads of the same model don't re-prompt.","Prefer transformers-native or GGUF builds of architectures you don't trust."],"tags":["model-loading","security","consent","trust-remote-code","frontend"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}