Claude Code Claude Opus 4.6 commited on
Commit
bca188b
·
1 Parent(s): 1a08408

Claude Code: Fix Docker path resolution in error_handlers.py - remove restrictive writable checks that fail at import time

Browse files
Files changed (1) hide show
  1. error_handlers.py +17 -15
error_handlers.py CHANGED
@@ -76,31 +76,33 @@ def _get_base_dir() -> Path:
76
 
77
  def _resolve_status_file() -> Path:
78
  """Find cain_status.json by searching common locations."""
79
- # Priority 1: /app/cain_status.json (Docker WORKDIR - primary location)
80
- app_path = Path("/app/cain_status.json")
81
- if app_path.parent.exists() and os.access(app_path.parent, os.W_OK):
82
- return app_path
83
-
84
- # Priority 2: CAIN_STATUS_PATH env var (direct override)
85
  env_path = os.environ.get('CAIN_STATUS_PATH')
86
  if env_path:
87
  return Path(env_path)
88
 
89
- # Priority 3: OPENCLAW_DATA_DIR with writable check
90
- base_dir = _get_base_dir()
91
- candidate = base_dir / "cain_status.json"
92
- if candidate.parent.exists() and os.access(candidate.parent, os.W_OK):
93
- return candidate
94
 
95
- # Priority 4: Script directory as final fallback
 
 
 
 
 
 
 
 
 
 
96
  script_dir = Path(os.path.dirname(__file__))
97
  return script_dir / "cain_status.json"
98
 
99
  STATUS_FILE = _resolve_status_file()
100
 
101
- # Ensure parent directory exists with proper permissions
102
- STATUS_FILE.parent.mkdir(parents=True, exist_ok=True)
103
-
104
 
105
  def handle_status_file_read() -> Dict[str, Any]:
106
  """
 
76
 
77
  def _resolve_status_file() -> Path:
78
  """Find cain_status.json by searching common locations."""
79
+ # Priority 1: CAIN_STATUS_PATH env var (set by app.py from OPENCLAW_DATA_DIR)
 
 
 
 
 
80
  env_path = os.environ.get('CAIN_STATUS_PATH')
81
  if env_path:
82
  return Path(env_path)
83
 
84
+ # Priority 2: /app/cain_status.json (Docker WORKDIR - primary location)
85
+ # Don't check writability here - directory may not exist yet but can be created
86
+ app_path = Path("/app/cain_status.json")
87
+ if app_path.parent.exists():
88
+ return app_path
89
 
90
+ # Priority 3: OPENCLAW_DATA_DIR
91
+ data_dir = os.environ.get('OPENCLAW_DATA_DIR')
92
+ if data_dir:
93
+ return Path(data_dir) / "cain_status.json"
94
+
95
+ # Priority 4: /data (standard Docker volume mount)
96
+ data_path = Path("/data/cain_status.json")
97
+ if data_path.parent.exists():
98
+ return data_path
99
+
100
+ # Priority 5: Script directory as final fallback
101
  script_dir = Path(os.path.dirname(__file__))
102
  return script_dir / "cain_status.json"
103
 
104
  STATUS_FILE = _resolve_status_file()
105
 
 
 
 
106
 
107
  def handle_status_file_read() -> Dict[str, Any]:
108
  """