Skip to content

Commit f464524

Browse files
authored
Merge pull request #268 from vicsanity623/revert-265-vicsanity623-patch-1
Revert "Update reviewer_mixins.py"
2 parents aa252b8 + b929829 commit f464524

1 file changed

Lines changed: 6 additions & 42 deletions

File tree

src/pyob/reviewer_mixins.py

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,6 @@ def _fix_runtime_errors(
244244
self, logs: str, entry_file: str, context_of_change: str = ""
245245
):
246246
"""Detects crashes. Handles missing packages automatically, otherwise asks AI."""
247-
248-
# --- 0. SANITIZE TARGET ---
249-
# Prevent the bot from hallucinating log headers as filenames
250-
if entry_file == "Validation Suite" or "Validation Suite" in entry_file:
251-
# Fallback to searching for a real file in the logs or use the project main
252-
found_file = getattr(self, "_find_entry_file")()
253-
entry_file = found_file if found_file else "main.js"
254-
255247
package_match = re.search(r"ModuleNotFoundError: No module named '(.*?)'", logs)
256248
if not package_match:
257249
package_match = re.search(r"ImportError: No module named '(.*?)'", logs)
@@ -320,44 +312,20 @@ def _fix_runtime_errors(
320312
except subprocess.CalledProcessError as e:
321313
logger.error(f"Failed to install {pkg} automatically: {e}")
322314

323-
# --- 1. SMART FILE IDENTIFICATION ---
324-
# Look for Python tracebacks first
325315
tb_files = re.findall(r'File "([^"]+)"', logs)
326-
327-
# NEW: Look for JavaScript/HTML filenames if Python search fails
328-
if not tb_files:
329-
tb_files = re.findall(r"([\w\-/]+\.(?:js|html|css))", logs)
330-
331316
target_file = entry_file
332317
for f in reversed(tb_files):
333-
# Block the "Validation Suite" hallucination here too
334-
if "Validation Suite" in f:
335-
continue
336-
337-
abs_f = (
338-
os.path.abspath(f)
339-
if os.path.isabs(f)
340-
else os.path.join(self.target_dir, f)
341-
)
342-
318+
abs_f = os.path.abspath(f)
343319
if (
344320
abs_f.startswith(self.target_dir)
345-
and not any(ign in abs_f for ign in getattr(self, "IGNORE_DIRS", []))
321+
and not any(ign in abs_f for ign in IGNORE_DIRS)
346322
and os.path.exists(abs_f)
347323
):
348324
target_file = abs_f
349325
break
350-
351-
# Ensure we have a valid path before proceeding
352-
if not os.path.exists(target_file):
353-
target_file = entry_file
354-
355326
rel_path = os.path.relpath(target_file, self.target_dir)
356-
357-
# --- 2. LOAD CODE AND PROMPT ---
358-
with open(target_file, "r", encoding="utf-8", errors="ignore") as f_obj:
327+
with open(target_file, "r", encoding="utf-8") as f_obj:
359328
code = f_obj.read()
360-
361329
if context_of_change:
362330
logger.info(
363331
f"Applying CONTEXT-AWARE fix for runtime crash in `{rel_path}`..."
@@ -372,8 +340,8 @@ def _fix_runtime_errors(
372340
else:
373341
logger.info(f"Applying standard fix for runtime crash in `{rel_path}`...")
374342
memory_section = (
375-
f"### Project Memory / Context:\n{getattr(self, 'memory', '')}\n\n"
376-
if getattr(self, "memory", None)
343+
f"### Project Memory / Context:\n{self.memory}\n\n"
344+
if self.memory
377345
else ""
378346
)
379347
prompt = getattr(self, "load_prompt")(
@@ -383,21 +351,17 @@ def _fix_runtime_errors(
383351
rel_path=rel_path,
384352
code=code,
385353
)
386-
387-
# --- 3. EXECUTE REPAIR ---
388354
new_code, explanation, _ = getattr(self, "get_valid_edit")(
389355
prompt, code, require_edit=True, target_filepath=target_file
390356
)
391-
392357
if new_code != code:
393358
with open(target_file, "w", encoding="utf-8") as f_out:
394359
f_out.write(new_code)
395360
logger.info(f"AI Auto-patched runtime crash in `{rel_path}`")
396361
self.session_context.append(
397362
f"Auto-fixed runtime crash in `{rel_path}`: {explanation}"
398363
)
399-
if hasattr(self, "run_linter_fix_loop"):
400-
self.run_linter_fix_loop()
364+
self.run_linter_fix_loop()
401365

402366
def check_downstream_breakages(self, target_path: str, rel_path: str) -> bool:
403367
logger.info(

0 commit comments

Comments
 (0)