{"record":{"id":"d34578ec6d3f8fa8","repo":"chenfei-wu/TaskMatrix","slug":"internal-errors","errorCode":null,"errorMessage":"internal errors","messagePattern":"internal errors","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"LowCodeLLM/src/app.py","lineNumber":35,"sourceCode":"    '%(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\n@app.route('/api/execute', methods=['POST'])\r\n@cross_origin()\r","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/chenfei-wu/TaskMatrix/blob/4b7664f8d3a23804ac1b795d75a73efd162769f0/LowCodeLLM/src/app.py#L17-L53","documentation":"Generic 500 response body returned by /api/get_workflow when any exception occurs during processing. It deliberately hides details; the real cause is only in the server log (the sibling 'failed to get_workflow' message).","triggerScenarios":"Same handler as index 0: malformed/missing JSON, missing task_prompt key, or OpenAI call failure inside llm.get_workflow all produce this {'errmsg': 'internal errors'} 500 response.","commonSituations":"Client sees only this opaque message because the server hides the exception; developer must read the server-side log to distinguish bad input (4xx-class mistake) from OpenAI/config problems.","solutions":["Reproduce while tailing the Flask logs and read the 'failed to get_workflow, msg:...' line for the underlying exception.","Fix the named cause: KeyError -> send task_prompt as JSON; openai errors -> fix key/env config.","Consider returning 400 for client-input errors instead of blanket 500s so callers can distinguish."],"exampleFix":"// before\nreturn {'errmsg': 'internal errors'}, 500\n// after (app.py)\nexcept KeyError as e:\n    return {'errmsg': f'missing field: {str(e)}'}, 400\nexcept Exception as e:\n    app.logger.error('failed to get_workflow, msg:%s' % str(e))\n    return {'errmsg': 'internal errors'}, 500","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp = requests.post(url, json=payload)\nif resp.status_code == 500 and resp.json().get('errmsg') == 'internal errors':\n    # opaque: inspect server log; do not blindly retry input errors","preventionTips":["Check for 400-style payload mistakes locally before blaming the server","Keep server logs accessible when debugging 500s"],"tags":["flask","http-500","error-handling","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"}