_ensure_safe_output_path() — langchain Function Reference
Architecture documentation for the _ensure_safe_output_path() function in cli.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 639f6001_e33f_cabc_b166_c58c92df4410["_ensure_safe_output_path()"] 74c7ffe0_0dd5_5e6a_45ab_950da26de248["cli.py"] 639f6001_e33f_cabc_b166_c58c92df4410 -->|defined in| 74c7ffe0_0dd5_5e6a_45ab_950da26de248 67e62d64_96d5_5560_dfce_06308c08d58a["_write_profiles_file()"] 67e62d64_96d5_5560_dfce_06308c08d58a -->|calls| 639f6001_e33f_cabc_b166_c58c92df4410 style 639f6001_e33f_cabc_b166_c58c92df4410 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/model-profiles/langchain_model_profiles/cli.py lines 146–170
def _ensure_safe_output_path(base_dir: Path, output_file: Path) -> None:
"""Ensure the resolved output path remains inside the expected directory."""
if base_dir.exists() and base_dir.is_symlink():
msg = f"Data directory {base_dir} is a symlink; refusing to write profiles."
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
if output_file.exists() and output_file.is_symlink():
msg = (
f"profiles.py at {output_file} is a symlink; refusing to overwrite it.\n"
"Delete the symlink or point --data-dir to a safe location."
)
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
try:
output_file.resolve(strict=False).relative_to(base_dir.resolve())
except (OSError, RuntimeError) as e:
msg = f"Failed to resolve output path: {e}"
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
except ValueError:
msg = f"Refusing to write outside of data directory: {output_file}"
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _ensure_safe_output_path() do?
_ensure_safe_output_path() is a function in the langchain codebase, defined in libs/model-profiles/langchain_model_profiles/cli.py.
Where is _ensure_safe_output_path() defined?
_ensure_safe_output_path() is defined in libs/model-profiles/langchain_model_profiles/cli.py at line 146.
What calls _ensure_safe_output_path()?
_ensure_safe_output_path() is called by 1 function(s): _write_profiles_file.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free