chenfei-wu/TaskMatrix · error

failed to get_workflow, msg:%s, request data:%s

Error message

failed to get_workflow, msg:%s, request data:%s

What it means

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.

Source

Thrown at LowCodeLLM/src/app.py:33

app.logger = gunicorn_logger
logging_format = logging.Formatter(
    '%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s')
default_handler.setFormatter(logging_format)

@app.route("/")
def index():
    return send_from_directory(".", "index.html")

@app.route('/api/get_workflow', methods=['POST'])
@cross_origin()
def get_workflow():
    try:
        request_content = request.get_json()
        task_prompt = request_content['task_prompt']
        workflow = llm.get_workflow(task_prompt)
        return workflow, 200
    except Exception as e:
        app.logger.error(
            'failed to get_workflow, msg:%s, request data:%s' % (str(e), request.json))
        return {'errmsg': 'internal errors'}, 500

@app.route('/api/extend_workflow', methods=['POST'])
@cross_origin()
def extend_workflow():
    try:
        request_content = request.get_json()
        task_prompt = request_content['task_prompt']
        current_workflow = request_content['current_workflow']
        step = request_content['step']
        sub_workflow = llm.extend_workflow(task_prompt, current_workflow, step)
        return sub_workflow, 200
    except Exception as e:
        app.logger.error(
            'failed to extend_workflow, msg:%s, request data:%s' % (str(e), request.json))
        return {'errmsg': 'internal errors'}, 500

View on GitHub (pinned to 4b7664f8d3)

Solutions

  1. Check the Flask log line: the msg:%s part names the actual exception (e.g. KeyError 'task_prompt' vs openai.AuthenticationError).
  2. Verify the request is POST with a JSON body containing task_prompt and Content-Type: application/json.
  3. Ensure OPENAIKEY is set (and API_BASE, API_VERSION, MODEL when USE_AZURE=true) in the shell that starts app.py.

Example fix

// before
curl -X POST http://localhost:5000/api/get_workflow -d '{"prompt":"x"}'
// after
curl -X POST http://localhost:5000/api/get_workflow \
  -H 'Content-Type: application/json' \
  -d '{"task_prompt":"write an essay"}'
Defensive patterns

Strategy: validation

Validate before calling

// client-side before POST /api/get_workflow
const body = {task_prompt: String(prompt)};
if (!body.task_prompt) throw new Error('task_prompt required');
await fetch('/api/get_workflow', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body)});

Try / catch

try { const r = await fetch(...); if (r.status === 500) console.error('server log has details'); } catch (e) { /* network-level failure */ }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of chenfei-wu/TaskMatrix@4b7664f8d3 (2026-08-27). Data as JSON: /api/errors/e2fded5b5ad0df73. Report an issue: GitHub.