Claude Code Claude Opus 4.6 commited on
Commit
2ae943a
·
1 Parent(s): 5e8b843

Claude Code: Fix STATUS_FILE path - use Path(__file__).parent instead of os.getcwd()

Browse files

- Changed error_handlers.py to use absolute path based on file location
- Matches pattern used in brain_minimal.py for consistency
- Resolves discrepancy between local (/tmp/claude-workpace) and container (/app) paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. error_handlers.py +4 -3
error_handlers.py CHANGED
@@ -6,6 +6,7 @@ Provides specific exception handlers for common operations.
6
  import json
7
  import os
8
  from datetime import datetime
 
9
  from typing import Dict, Any, Optional
10
  from fastapi import HTTPException, Request
11
  from fastapi.responses import JSONResponse
@@ -57,8 +58,8 @@ async def generic_exception_handler(request: Request, exc: Exception) -> JSONRes
57
 
58
 
59
  # Configuration path - cain_status.json location
60
- # Uses current working directory which resolves to /app in container, /tmp/claude-workspace locally
61
- STATUS_FILE = os.path.join(os.getcwd(), "openclaw", ".openclaw", "agents", "cain_status.json")
62
 
63
 
64
  def handle_status_file_read() -> Dict[str, Any]:
@@ -69,7 +70,7 @@ def handle_status_file_read() -> Dict[str, Any]:
69
  Status dictionary with current_state, last_updated, and agent fields.
70
  """
71
  try:
72
- with open(STATUS_FILE, "r") as f:
73
  return json.load(f)
74
  except FileNotFoundError:
75
  # Status file not found is not an error - return healthy default
 
6
  import json
7
  import os
8
  from datetime import datetime
9
+ from pathlib import Path
10
  from typing import Dict, Any, Optional
11
  from fastapi import HTTPException, Request
12
  from fastapi.responses import JSONResponse
 
58
 
59
 
60
  # Configuration path - cain_status.json location
61
+ # Uses absolute path based on this file's location (works both locally and in container)
62
+ STATUS_FILE = Path(__file__).parent / "openclaw" / ".openclaw" / "agents" / "cain_status.json"
63
 
64
 
65
  def handle_status_file_read() -> Dict[str, Any]:
 
70
  Status dictionary with current_state, last_updated, and agent fields.
71
  """
72
  try:
73
+ with open(str(STATUS_FILE), "r") as f:
74
  return json.load(f)
75
  except FileNotFoundError:
76
  # Status file not found is not an error - return healthy default