Refactor Plan errors
Errors in the refactor plan feature fall into two categories: failures during workflow execution (orchestrating the three subagents and synthesizing their output) and failures during report formatting (converting the raw result into a human-readable report).
Common error signatures
Errors most commonly appear in these forms:
- Missing or invalid path —
RefactorPlanWorkflow.execute()receives a path that doesn't exist or isn't accessible, causing the workflow to fail before any subagent runs. - Malformed result dict —
format_refactor_plan_report(result, input_data)raises aKeyErrororTypeErrorwhenresultis missing expected keys (such asSummary,Refactoring, orSuggestionssections) or wheninput_dataisNone. - Subagent synthesis failure — the orchestrator (
debt-scanner,impact-analyzer, orplan-generator) returns an incomplete response, leavingresultin a partial state thatformat_refactor_plan_report()cannot render. - CLI argument error —
main()exits early if required arguments are not supplied or are in an unexpected format.
Where errors originate
RefactorPlanWorkflow.execute()— orchestrates the three subagents and produces aWorkflowResult. Failures here usually indicate a bad input path, a subagent that did not complete, or a synthesis step that produced unexpected output structure.format_refactor_plan_report(result, input_data)— converts the workflow'sresultdict and the originalinput_datadict into a readable report string. Failures here usually meanexecute()returned a result dict that is missing required sections or has an unexpected shape.main()— the CLI entry point that wires together argument parsing,RefactorPlanWorkflow, andformat_refactor_plan_report(). Errors here are often missing CLI arguments or an unhandled exception bubbling up from one of the two functions above.
How to diagnose
-
Read the traceback call stack top-to-bottom. Identify whether the raise site is in
refactor_plan.py(workflow/subagent layer) orrefactor_plan_report.py(formatting layer). That tells you which half of the pipeline failed. -
Check the exception type at the raise site.
- A
KeyErrorinformat_refactor_plan_report()meansresultis missing a key the formatter expects — inspect the dict returned byexecute()to see what sections are present. - A
TypeErrorinformat_refactor_plan_report()often meansresultorinput_dataisNone, which points back toexecute()returning an empty or failedWorkflowResult. - An
OSErrororFileNotFoundErrorinexecute()means the path passed to the workflow does not exist or is not readable.
- A
-
Inspect the
resultdict before formatting. If you can reproduce the failure, print or log the value ofresultafterexecute()returns and before passing it toformat_refactor_plan_report(). The three expected top-level sections areSummary,Refactoring, andSuggestions— a missing section identifies which subagent (debt-scanner,impact-analyzer, orplan-generator) did not complete successfully. -
Verify the path argument. The
_TASK_PROMPT_TEMPLATErequires a{path}value. Ifmain()is the entry point, confirm the path argument was supplied and points to a readable file or directory.
Source files
src/attune/workflows/refactor_plan.pysrc/attune/workflows/refactor_plan_report.py
Tags: refactor, tech-debt, complexity