{"record":{"id":"4e588a8517012aaa","repo":"chenfei-wu/TaskMatrix","slug":"failed-to-extend-workflow-msg-s-request-data-s","errorCode":null,"errorMessage":"failed to extend_workflow, msg:%s, request data:%s","messagePattern":"failed to extend_workflow, msg:(.+?), request data:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"LowCodeLLM/src/app.py","lineNumber":48,"sourceCode":"        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\n@app.route('/api/execute', methods=['POST'])\r\n@cross_origin()\r\ndef execute():\r\n    try:\r\n        request_content = request.get_json()\r\n        task_prompt = request_content['task_prompt']\r\n        confirmed_workflow = request_content['confirmed_workflow']\r\n        curr_input = request_content['curr_input']\r\n        history = request_content['history']\r\n        response = llm.execute(task_prompt,confirmed_workflow, history, curr_input)\r\n        return response, 200\r\n    except Exception as e:\r\n        app.logger.error(\r\n            'failed to execute, msg:%s, request data:%s' % (str(e), request.json))\r\n        return {'errmsg': 'internal errors'}, 500\r","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/chenfei-wu/TaskMatrix/blob/4b7664f8d3a23804ac1b795d75a73efd162769f0/LowCodeLLM/src/app.py#L30-L66","documentation":"Flask error log from the /api/extend_workflow endpoint. Thrown when the JSON body lacks task_prompt/current_workflow/step, or when llm.extend_workflow fails (OpenAI error or SOP format parse failure).","triggerScenarios":"POST /api/extend_workflow missing any of the three required keys ('task_prompt', 'current_workflow', 'step'), sending non-JSON, or an OpenAI failure (bad/missing OPENAIKEY, Azure misconfiguration) inside planningLLM.extend_workflow.","commonSituations":"Frontend sends current_workflow as a dict instead of the JSON string the prompt-building code concatenates, one key is misspelled, or env vars for OpenAI/Azure are not exported in the server process.","solutions":["Read the logged msg:%s to identify the exception (KeyError vs openai error).","Ensure the body contains all three fields as JSON: task_prompt (string), current_workflow (string), step (string).","Verify OPENAIKEY and, if USE_AZURE=true, API_BASE/API_VERSION/MODEL are set for the server process."],"exampleFix":"// before\ncurl -X POST .../api/extend_workflow -d '{\"step\":\"write\"}'\n// after\ncurl -X POST .../api/extend_workflow \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"task_prompt\":\"essay\",\"current_workflow\":\"STEP 1: ...\",\"step\":\"write the text\"}'","handlingStrategy":"validation","validationCode":"assert all(k in body for k in ('task_prompt','current_workflow','step')) and all(isinstance(body[k], str) for k in body)","typeGuard":"def is_extend_payload(b) -> bool:\n    return (isinstance(b, dict)\n            and isinstance(b.get('task_prompt'), str)\n            and isinstance(b.get('current_workflow'), str)\n            and isinstance(b.get('step'), str))","tryCatchPattern":"try: requests.post(url, json=body, timeout=30).raise_for_status()\nexcept requests.HTTPError as e: log(e.response.text)","preventionTips":["Send current_workflow as the JSON string exactly as returned by get_workflow","Validate all three string fields client-side"],"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"}