ruvnet/RuView · error · ValueError
Failed to save domain configuration: {e}
Error message
Failed to save domain configuration: {e} What it means
Wrapper exception in save_domain_config_to_file in archive/v1/src/config/domains.py. It serializes the config with config.to_dict() and json.dump(...)s it to the given path; any failure — unwritable destination (PermissionError), missing parent directory (FileNotFoundError), or TypeError from non-JSON-serializable values in to_dict() — is re-raised as ValueError('Failed to save domain configuration: {e}').
Source
Thrown at archive/v1/src/config/domains.py:481
# Load alerts config
if "alerts" in data:
config.alerts = AlertConfig(**data["alerts"])
except Exception as e:
raise ValueError(f"Failed to load domain configuration: {e}")
return config
def save_domain_config_to_file(config: DomainConfig, file_path: str):
"""Save domain configuration to file."""
import json
try:
with open(file_path, 'w') as f:
json.dump(config.to_dict(), f, indent=2)
except Exception as e:
raise ValueError(f"Failed to save domain configuration: {e}")View on GitHub (pinned to 4685618388)
Solutions
- Read the chained message after 'Failed to save domain configuration:' to distinguish permission vs serialization errors
- Create parent directories first: Path(file_path).parent.mkdir(parents=True, exist_ok=True)
- If TypeError, make to_dict() return JSON-safe values or pass default=str to json.dump
- Verify write permission on the directory (touch a temp file) before saving
Example fix
# before
with open(file_path, 'w') as f:
json.dump(config.to_dict(), f, indent=2)
# after
from pathlib import Path
Path(file_path).parent.mkdir(parents=True, exist_ok=True)
with open(file_path, 'w') as f:
json.dump(config.to_dict(), f, indent=2, default=str) Defensive patterns
Strategy: try-catch
Validate before calling
import json, os
from pathlib import Path
dest = Path("config/domains.json")
dest.parent.mkdir(parents=True, exist_ok=True)
assert os.access(dest.parent, os.W_OK), f"no write permission in {dest.parent}"
json.dumps(config.to_dict(), default=str) # serialization errors surface here Type guard
def is_json_serializable(obj) -> bool:
try:
json.dumps(obj, default=str)
return True
except (TypeError, ValueError):
return False Try / catch
try:
save_domain_config_to_file(config, path)
except ValueError as e:
# distinguishes permission vs serialization failures via the chained message
raise RuntimeError(f"config save failed: {e}") from None Prevention
- Create parent directories and confirm write access before saving
- Keep to_dict() output JSON-safe (primitives only) or pass default=str
- Write to a temp file then atomically rename so a failed save never truncates the config
When it happens
Trigger: Saving to a path whose parent directory does not exist; saving into a read-only mount or a directory without write permission; to_dict() containing datetime, numpy, or set values that json.dump cannot serialize (TypeError: Object of type X is not JSON serializable); disk full during write.
Common situations: First run writing to data/config/domains.json before creating data/config; containers with read-only config volumes; configs enriched with runtime objects (timestamps, model handles) that were never converted to primitives.
Related errors
- Failed to load domain configuration: {e}
- {path}: expected {{'nodes': [...]}} or a top-level list
- Threshold must be between 0.0 and 1.0
- FPS must be between 1 and 60
- Compression level must be between 1 and 9
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/468593dab7261053.
Report an issue: GitHub.