{"record":{"id":"9ca59d75fbf52808","repo":"xtekky/gpt4free","slug":"failed-to-extract-nonce-sig-from-data-json-got","errorCode":null,"errorMessage":"Failed to extract nonce/sig from __data.json. Got: {tap_data}","messagePattern":"Failed to extract nonce/sig from __data\\.json\\. Got: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/BraveSearch.py","lineNumber":273,"sourceCode":"\n            data_params = {\n                \"q\": prompt,\n                \"x-sveltekit-invalidated\": \"11\",\n            }\n            if is_deep:\n                data_params[\"enable_research\"] = \"true\"\n\n            async with session.get(\n                DATA_ENDPOINT, params=data_params, headers={\"referer\": referer}\n            ) as response:\n                await raise_for_status(response)\n                data_json = await response.json()\n                tap_data = cls._parse_sveltekit_tap_data(data_json)\n\n                nonce = tap_data.get(\"nonce\")\n                sig = tap_data.get(\"sig\")\n                if not nonce or not sig:\n                    raise RuntimeError(\n                        \"Failed to extract nonce/sig from __data.json. \"\n                        f\"Got: {tap_data}\"\n                    )\n                conversation.nonce = nonce\n                conversation.sig = sig\n                debug.log(f\"BraveSearch: Got nonce={nonce[:8]}... sig={sig[:8]}...\")\n\n            # ===== STEP 2: Create new conversation =====\n            new_params = {\n                \"language\": \"en\",\n                \"country\": \"us\",\n                \"ui_lang\": \"en-us\",\n                \"safesearch\": \"moderate\",\n                \"force_safesearch\": \"0\",\n                \"units_of_measurement\": \"metric\",\n                \"use_location\": \"1\",\n                \"geoloc\": \"50.457x30.532\",\n                \"premium_cookie_name\": \"__Secure-sku#brave-search-premium\",","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/BraveSearch.py#L255-L291","documentation":"io.ReadAll on the opened embedded archive failed. For an embed.FS file this only happens on a genuine I/O error; in practice it surfaces when the embedded bytes are truncated or the read is interrupted, and it wraps the underlying error with %w for diagnosis.","triggerScenarios":"Reading a corrupted or zero-length zip that passed the embed step; extremely large archives exhausting memory during ReadAll (OOM-kill surfaces as a read error on some platforms); a corrupted build cache providing bad embedded data.","commonSituations":"fetch-python.sh downloading a partial zip (interrupted network) that then got embedded; CI runners with tight memory limits embedding a large runtime zip; disk corruption or an aggressive cache cleaner touching GOCACHE.","solutions":["Inspect the wrapped %w error — it distinguishes I/O failure from truncation","Re-fetch the archive (delete embed cache, rerun fetch-python.sh) verifying the zip's size/checksum, then rebuild","go clean -cache and rebuild to eliminate a corrupted embed cache","If memory limits are the cause (huge archive + ReadAll), stream-extract with zip.NewReader over the embed.FS file instead of buffering all bytes"],"exampleFix":"// before\ndata, err := io.ReadAll(src)\nsrc.Close()\nif err != nil {\n    return fmt.Errorf(\"read embedded archive: %w\", err)\n}\nif err := extractZip(bytes.NewReader(data), int64(len(data)), binDir); err != nil {\n\n// after\nzr, err := zip.NewReader(src, info.Size()) // src is embed fs.File; use Stat() for size\nif err != nil {\n    return fmt.Errorf(\"read embedded archive: %w\", err)\n}\n// extract from zr directly without buffering the whole archive","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"data, err := io.ReadAll(src)\nsrc.Close()\nif err != nil {\n    return fmt.Errorf(\"read embedded archive: %w\", err)\n}\n// Distinguish corruption from environment: fail fast, never retry a bad embed.\n// Repair path is always: re-fetch archive + rebuild binary.","preventionTips":["Verify zip integrity in fetch-python.sh (unzip -t or a checksum) before embedding","Stream-extract with zip.NewReader instead of ReadAll to avoid memory-driven read failures on large runtimes"],"tags":["embed","io","memory","zip"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}