{"record":{"id":"a3abbc7748466379","repo":"xtekky/gpt4free","slug":"no-user-message-found-in-messages","errorCode":null,"errorMessage":"No user message found in messages","messagePattern":"No user message found in messages","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/BraveSearch.py","lineNumber":224,"sourceCode":"            for message in reversed(messages):\n                if message[\"role\"] == \"user\":\n                    prompt = message[\"content\"]\n                    if isinstance(prompt, list):\n                        prompt = (\n                            \"\\n\".join(\n                                [\n                                    item.get(\"text\", \"\")\n                                    for item in prompt\n                                    if isinstance(item, dict)\n                                ]\n                            )\n                            if prompt\n                            else \"\"\n                        )\n                    break\n\n        if not prompt:\n            raise ValueError(\"No user message found in messages\")\n\n        # Initialize conversation if needed\n        if conversation is None:\n            conversation = Conversation()\n\n        headers = {\n            \"accept\": \"application/json\",\n            \"accept-language\": \"en-US,en;q=0.9\",\n            \"cache-control\": \"no-cache\",\n            \"pragma\": \"no-cache\",\n            \"user-agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 \"\n            \"(KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36\",\n        }\n\n        # Deep Research needs a much longer timeout\n        timeout = DEEP_RESEARCH_TIMEOUT if is_deep else 120\n\n        async with StreamSession(","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/BraveSearch.py#L206-L242","documentation":"After picking an archive entry from the embed FS, fs.Open on that exact name failed. Since the name came from the same FS's directory listing, this is nearly impossible unless the embed pattern, build cache, or the embedded data is inconsistent (e.g. stale go build cache after archives changed on disk).","triggerScenarios":"A stale Go build cache serving an embed FS whose directory listing and file contents disagree; manual tampering with embed/<os>/ between builds; an embed pattern that matched a directory entry rather than a file which pickArchive then selects.","commonSituations":"Rebuilding right after fetch-python.sh replaced archives while an old build cache is reused; pickArchive selecting a non-zip entry (e.g. a README or directory) that listing returned; unusual filesystem casing issues on case-sensitive hosts.","solutions":["Clean the build cache and rebuild: go clean -cache then go build — a stale cache is the most common cause","Inspect embed/<os>/ contents: ensure only the expected <os>-<arch>-embed-<ver>.zip files are present and pickArchive's filter (in runtime.go above extractEmbedded) only matches zip files","Tighten the go:embed pattern to embed/<os>/*.zip so non-archive entries can never be listed","Run go vet / rebuild in a fresh module cache to rule out a corrupted embed"],"exampleFix":"// before\n//go:embed embed/*\nvar embedRuntimeArchive embed.FS\n\n// after\n//go:embed embed/*/*.zip\nvar embedRuntimeArchive embed.FS","handlingStrategy":"validation","validationCode":"entries, err := embeddedArchives()\nif err != nil || len(entries) == 0 {\n    return fmt.Errorf(\"no embedded runtime archive for this platform (run fetch-python.sh and rebuild)\")\n}\nif _, statErr := embedRuntimeArchive.Open(entries[0]); statErr != nil {\n    // embed FS inconsistent; force clean rebuild\n    return fmt.Errorf(\"embed FS inconsistent for %s: %w (go clean -cache and rebuild)\", entries[0], statErr)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run go clean -cache (or use -a) in CI after archives change","Constrain the embed glob to *.zip so directory entries can never be picked"],"tags":["embed","build-cache","go"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}