xtekky/gpt4free · error · RuntimeError
Failed to extract nonce/sig from __data.json. Got: {tap_data
Error message
Failed to extract nonce/sig from __data.json. Got: {tap_data} What it means
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.
Source
Thrown at g4f/Provider/BraveSearch.py:273
data_params = {
"q": prompt,
"x-sveltekit-invalidated": "11",
}
if is_deep:
data_params["enable_research"] = "true"
async with session.get(
DATA_ENDPOINT, params=data_params, headers={"referer": referer}
) as response:
await raise_for_status(response)
data_json = await response.json()
tap_data = cls._parse_sveltekit_tap_data(data_json)
nonce = tap_data.get("nonce")
sig = tap_data.get("sig")
if not nonce or not sig:
raise RuntimeError(
"Failed to extract nonce/sig from __data.json. "
f"Got: {tap_data}"
)
conversation.nonce = nonce
conversation.sig = sig
debug.log(f"BraveSearch: Got nonce={nonce[:8]}... sig={sig[:8]}...")
# ===== STEP 2: Create new conversation =====
new_params = {
"language": "en",
"country": "us",
"ui_lang": "en-us",
"safesearch": "moderate",
"force_safesearch": "0",
"units_of_measurement": "metric",
"use_location": "1",
"geoloc": "50.457x30.532",
"premium_cookie_name": "__Secure-sku#brave-search-premium",View on GitHub (pinned to 973504e177)
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
Example fix
// before
data, err := io.ReadAll(src)
src.Close()
if err != nil {
return fmt.Errorf("read embedded archive: %w", err)
}
if err := extractZip(bytes.NewReader(data), int64(len(data)), binDir); err != nil {
// after
zr, err := zip.NewReader(src, info.Size()) // src is embed fs.File; use Stat() for size
if err != nil {
return fmt.Errorf("read embedded archive: %w", err)
}
// extract from zr directly without buffering the whole archive Defensive patterns
Strategy: try-catch
Try / catch
data, err := io.ReadAll(src)
src.Close()
if err != nil {
return fmt.Errorf("read embedded archive: %w", err)
}
// Distinguish corruption from environment: fail fast, never retry a bad embed.
// Repair path is always: re-fetch archive + rebuild binary. Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No audio chunks
- No user message found in messages
- Failed to get conversation ID from /new: {new_data}
- archive has no top-level directory
- unsafe path in archive: %s
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/9ca59d75fbf52808.
Report an issue: GitHub.