Add automated auto-fix workflow and diagnostics helpers#9
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _parse_auto_fix_completion(text: str) -> Dict[str, Any]: | ||
| parsed = _extract_auto_fix_json(text) | ||
| if not parsed: | ||
| return { | ||
| "status": "unparsed", | ||
| "summary": (text or "").strip(), | ||
| "actions": [], | ||
| "fix_instructions": "", | ||
| "metrics": {}, | ||
| "parsed": None, | ||
| "raw": text, | ||
| } | ||
|
|
||
| status = str(parsed.get("status", "")).lower().strip() | ||
| if status not in _VALID_AUTO_FIX_STATUSES: | ||
| status = "unparsed" | ||
|
|
||
| actions_raw = parsed.get("actions") or parsed.get("action_items") or [] | ||
| if isinstance(actions_raw, str): | ||
| actions = [actions_raw.strip()] | ||
| else: | ||
| actions = [str(item) for item in actions_raw if item is not None] | ||
|
|
||
| fix_instructions = parsed.get("fix_instructions") or parsed.get("resolution") or "" | ||
| summary = parsed.get("summary") or parsed.get("analysis") or "" | ||
| metrics = parsed.get("metrics") or {} |
There was a problem hiding this comment.
Guard against non-object JSON in auto-fix parser
_parse_auto_fix_completion assumes _extract_auto_fix_json returns a mapping and immediately calls parsed.get(...). However _extract_auto_fix_json will happily return any valid JSON value, including a list or string when the model responds with [{...}] or "...". In those cases parsed.get raises an AttributeError, causing /infer/auto-fix to 500 instead of returning an "unparsed" status. Given LLM output is not guaranteed to respect the prompt, this makes the new endpoint brittle. Consider verifying isinstance(parsed, dict) and falling back to the unstructured branch when it is not.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68fa885a93588331b62a5489ff43b6b0