{"record":{"id":"733773362a547226","repo":"xtekky/gpt4free","slug":"line-6","errorCode":null,"errorMessage":"line[6:]","messagePattern":"line\\[6:\\]","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/You.py","lineNumber":142,"sourceCode":"            }\n            if chat_mode == \"custom\":\n                if debug.logging:\n                    print(f\"You model: {model}\")\n                data[\"selectedAiModel\"] = model.replace(\"-\", \"_\")\n\n            async with session.get(\n                f\"{cls.url}/api/streamingSearch\",\n                params=data,\n                headers=headers,\n                cookies=cookies,\n            ) as response:\n                await raise_for_status(response)\n                async for line in response.iter_lines():\n                    if line.startswith(b\"event: \"):\n                        event = line[7:].decode()\n                    elif line.startswith(b\"data: \"):\n                        if event == \"error\":\n                            raise ResponseError(line[6:])\n                        if event in [\"youChatUpdate\", \"youChatToken\"]:\n                            data = json.loads(line[6:])\n                        if event == \"youChatToken\" and event in data and data[event]:\n                            if data[event].startswith(\n                                \"#### You've hit your free quota for the Model Agent. For more usage of the Model Agent, learn more at:\"\n                            ):\n                                continue\n                            yield data[event]\n                        elif event == \"youChatUpdate\" and \"t\" in data and data[\"t\"]:\n                            if chat_mode == \"create\":\n                                match = re.search(r\"!\\[(.+?)\\]\\((.+?)\\)\", data[\"t\"])\n                                if match:\n                                    if match.group(1) == \"fig\":\n                                        yield ImagePreview(\n                                            match.group(2), messages[-1][\"content\"]\n                                        )\n                                    else:\n                                        yield ImageResponse(","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/You.py#L124-L160","documentation":"Raised as ResponseError while streaming You.com's /api/streamingSearch SSE feed when an 'event: error' line precedes a data line; the raw bytes after 'data: ' (line[6:]) are passed as the error payload. Note the slice yields bytes, so the raised error carries a bytes message rather than a string.","triggerScenarios":"You.com streaming endpoint reports an error event: invalid/expired cookies, quota exhaustion, or malformed search parameters.","commonSituations":"Stale you.com cookies, hitting usage limits, g4f's request payload no longer matching You.com's API expectations after an upstream change.","solutions":["Decode the bytes message (e[0] if tuple, or str) to see the actual upstream reason","Refresh you.com cookies (log in again) if the message indicates auth/quota","Retry with backoff for transient errors; switch provider if persistent"],"exampleFix":"# before\nfor chunk in streaming_call: ...\n# ResponseError(b'...') from you.com error event\n\n# after\ntry:\n    for chunk in streaming_call: ...\nexcept g4f.errors.ResponseError as e:\n    msg = e.args[0]\n    if isinstance(msg, bytes):\n        msg = msg.decode('utf-8', 'replace')\n    logging.error('you.com error: %s', msg)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import ResponseError\ntry:\n    for chunk in stream: process(chunk)\nexcept ResponseError as e:\n    msg = e.args[0]\n    msg = msg.decode('utf-8', 'replace') if isinstance(msg, bytes) else str(msg)\n    logging.error('you.com: %s', msg)\n    if 'quota' in msg.lower():\n        rotate_you_cookies()","preventionTips":["Expect bytes payloads from this raise; normalize before string matching","Keep you.com cookies fresh and catch ResponseError on every SSE loop"],"tags":["streaming","sse","upstream-error","you","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}