chenfei-wu/TaskMatrix · error

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

Error message

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

What it means

Flask error log from the /api/execute endpoint. Logged when the request body is missing task_prompt/confirmed_workflow/curr_input/history, or when llm.execute fails downstream (OpenAI API error in executingLLM).

Source

Thrown at LowCodeLLM/src/app.py:64

        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

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

View on GitHub (pinned to 4b7664f8d3)

Solutions

  1. Check the logged msg:%s for the concrete exception (usually KeyError or an openai error).
  2. Send all four fields as JSON; make history a list of {'role': 'user'|'assistant', 'content': str} objects.
  3. Verify OpenAI env vars (OPENAIKEY, and Azure vars if USE_AZURE=true) in the server environment.

Example fix

// before
{"task_prompt":"essay","curr_input":"hi"}
// after
{"task_prompt":"essay","confirmed_workflow":[...],"history":[{"role":"user","content":"hi"}],"curr_input":"what next?"}
Defensive patterns

Strategy: validation

Validate before calling

assert all(k in body for k in ('task_prompt','confirmed_workflow','curr_input','history'))
assert isinstance(body['history'], list) and all(set(m) >= {'role','content'} for m in body['history'])

Type guard

def is_valid_history(h) -> bool:
    return isinstance(h, list) and all(
        isinstance(m, dict) and m.get('role') in ('user','assistant','system')
        and isinstance(m.get('content'), str) for m in h)

Try / catch

try: ... except requests.HTTPError: check server 'failed to execute' log line

Prevention

When it happens

Trigger: POST /api/execute missing any of 'task_prompt', 'confirmed_workflow', 'curr_input', 'history', sending history in a format that breaks message concatenation (e.g. plain strings instead of [{'role':...,'content':...}] dicts), or an OpenAI failure.

Common situations: Frontend serializes history as strings or omits it; OPENAIKEY unset; history entries lack 'role'/'content' keys causing errors when passed to openai.ChatCompletion.create.

Related errors


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