{"record":{"id":"e2fded5b5ad0df73","repo":"chenfei-wu/TaskMatrix","slug":"failed-to-get-workflow-msg-s-request-data-s","errorCode":null,"errorMessage":"failed to get_workflow, msg:%s, request data:%s","messagePattern":"failed to get_workflow, msg:(.+?), request data:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"LowCodeLLM/src/app.py","lineNumber":33,"sourceCode":"app.logger = gunicorn_logger\r\nlogging_format = logging.Formatter(\r\n    '%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s')\r\ndefault_handler.setFormatter(logging_format)\r\n\r\n@app.route(\"/\")\r\ndef index():\r\n    return send_from_directory(\".\", \"index.html\")\r\n\r\n@app.route('/api/get_workflow', methods=['POST'])\r\n@cross_origin()\r\ndef get_workflow():\r\n    try:\r\n        request_content = request.get_json()\r\n        task_prompt = request_content['task_prompt']\r\n        workflow = llm.get_workflow(task_prompt)\r\n        return workflow, 200\r\n    except Exception as e:\r\n        app.logger.error(\r\n            'failed to get_workflow, msg:%s, request data:%s' % (str(e), request.json))\r\n        return {'errmsg': 'internal errors'}, 500\r\n\r\n@app.route('/api/extend_workflow', methods=['POST'])\r\n@cross_origin()\r\ndef extend_workflow():\r\n    try:\r\n        request_content = request.get_json()\r\n        task_prompt = request_content['task_prompt']\r\n        current_workflow = request_content['current_workflow']\r\n        step = request_content['step']\r\n        sub_workflow = llm.extend_workflow(task_prompt, current_workflow, step)\r\n        return sub_workflow, 200\r\n    except Exception as e:\r\n        app.logger.error(\r\n            'failed to extend_workflow, msg:%s, request data:%s' % (str(e), request.json))\r\n        return {'errmsg': 'internal errors'}, 500\r\n\r","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/chenfei-wu/TaskMatrix/blob/4b7664f8d3a23804ac1b795d75a73efd162769f0/LowCodeLLM/src/app.py#L15-L51","documentation":"This is a Flask error log emitted by the /api/get_workflow endpoint in LowCodeLLM/src/app.py. Any exception raised while parsing the request body ('task_prompt' missing from JSON) or while calling llm.get_workflow (OpenAI failure or workflow parsing failure) is caught and logged with this message before returning HTTP 500.","triggerScenarios":"POST /api/get_workflow with a body that is not JSON, is missing the 'task_prompt' key, or with an unset/failing OpenAI key (OPENAIKEY env var absent, invalid key, or Azure env vars missing when USE_AZURE=true).","commonSituations":"Forgetting to send Content-Type: application/json, omitting task_prompt in the request body, or running the Flask server without the OPENAIKEY / API_BASE / API_VERSION / MODEL environment variables exported.","solutions":["Check the Flask log line: the msg:%s part names the actual exception (e.g. KeyError 'task_prompt' vs openai.AuthenticationError).","Verify the request is POST with a JSON body containing task_prompt and Content-Type: application/json.","Ensure OPENAIKEY is set (and API_BASE, API_VERSION, MODEL when USE_AZURE=true) in the shell that starts app.py."],"exampleFix":"// before\ncurl -X POST http://localhost:5000/api/get_workflow -d '{\"prompt\":\"x\"}'\n// after\ncurl -X POST http://localhost:5000/api/get_workflow \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"task_prompt\":\"write an essay\"}'","handlingStrategy":"validation","validationCode":"// client-side before POST /api/get_workflow\nconst body = {task_prompt: String(prompt)};\nif (!body.task_prompt) throw new Error('task_prompt required');\nawait fetch('/api/get_workflow', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body)});","typeGuard":null,"tryCatchPattern":"try { const r = await fetch(...); if (r.status === 500) console.error('server log has details'); } catch (e) { /* network-level failure */ }","preventionTips":["Always send Content-Type: application/json","Include task_prompt in every request","Export OPENAIKEY before starting app.py"],"tags":["flask","http-500","request-parsing","openai","lowcodellm"],"backgroundTag":"http-500-internal-server-error","analyzedSha":"4b7664f8d3a23804ac1b795d75a73efd162769f0","analyzedAt":"2026-08-27T13:26:11.787Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}