Skip to content

Commit d05906c

Browse files
committed
fix(validator): consult platform_dirs and fall back to ~/.orb for config discovery
The validator's bespoke candidate list contained only ./config/config.json as the fallback, missing every platform root that ConfigurationManager resolves via platform_dirs.get_config_location(). Route the third candidate through get_config_location() and update _print_config_help to display the actual paths tried. When running from inside a repo checkout, platform_dirs rules 4b/5 pin the config location to the venv/checkout root regardless of whether config exists there. Add a final user-home fallback so operators with global ~/.orb config succeed when the local checkout has no config of its own.
1 parent 7207b98 commit d05906c

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

src/orb/infrastructure/validation/startup_validator.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,22 @@ def _find_config_file(self) -> bool:
106106
if self.config_path and Path(self.config_path).exists():
107107
return True
108108

109-
# Discovery hierarchy
109+
from pathlib import Path as _Path
110+
111+
from orb.config.platform_dirs import get_config_location
112+
113+
# Discovery hierarchy — must match ConfigurationManager's resolution order.
114+
# ORB_CONFIG_FILE and ORB_CONFIG_DIR/config.json are kept explicitly so the
115+
# validator can surface a meaningful error when they are set but wrong.
116+
# Then the platform-dirs path (respects venv / pyproject / uv-tool detection).
117+
# Finally the user-home path so operators running from inside a checkout
118+
# (which pins platform_dirs to the repo) still pick up ~/.orb/config/config.json
119+
# when the repo has no local config.
110120
candidates = [
111121
os.environ.get("ORB_CONFIG_FILE"),
112122
os.path.join(os.environ.get("ORB_CONFIG_DIR", ""), "config.json"),
113-
"./config/config.json",
123+
str(get_config_location() / "config.json"),
124+
str(_Path.home() / ".orb" / "config" / "config.json"),
114125
]
115126

116127
for candidate in candidates:
@@ -162,20 +173,23 @@ def _check_provider_credentials(self) -> bool:
162173

163174
def _print_config_help(self) -> None:
164175
"""Print helpful config location information."""
165-
from orb.config.services.path_resolution_service import PathResolutionService
166-
167-
svc = PathResolutionService()
176+
from orb.config.platform_dirs import get_config_location
168177

169178
self._console.info("")
170179
self._console.info("Configuration not found in:")
171180

172-
default_resolved = svc.resolve_file_path("template", "default_config.json")
173-
if default_resolved:
174-
self._console.info(f" - {default_resolved}")
175-
176-
config_resolved = svc.resolve_file_path("config", "config.json")
177-
if config_resolved:
178-
self._console.info(f" - {config_resolved}")
181+
# Show the explicit env-var paths when set, then the platform-dirs path.
182+
tried: list[str] = []
183+
env_file = os.environ.get("ORB_CONFIG_FILE")
184+
if env_file:
185+
tried.append(env_file)
186+
env_dir = os.environ.get("ORB_CONFIG_DIR")
187+
if env_dir:
188+
tried.append(os.path.join(env_dir, "config.json"))
189+
tried.append(str(get_config_location() / "config.json"))
190+
191+
for path in tried:
192+
self._console.info(f" - {path}")
179193

180194
self._console.info("")
181195
self._console.info("To initialize:")

0 commit comments

Comments
 (0)