MCPcopy Index your code
hub / github.com/google/adk-python / _parse_file_path

Method _parse_file_path

src/google/adk/cli/dev_server.py:247–261  ·  view source on GitHub ↗
(file_path: str)

Source from the content-addressed store, hash-verified

245 return rel_path
246
247 def _parse_file_path(file_path: str) -> str:
248 file_path = _normalize_relative_path(file_path)
249 if not file_path:
250 raise ValueError("file_path is missing.")
251 if file_path.startswith("/"):
252 raise ValueError(f"Absolute file_path rejected: {file_path!r}")
253 if _has_parent_reference(file_path):
254 raise ValueError(f"Path traversal rejected: {file_path!r}")
255 ext = os.path.splitext(file_path)[1].lower()
256 if ext not in _ALLOWED_EXTENSIONS:
257 raise ValueError(
258 f"File type not allowed: {file_path!r}"
259 f" (allowed: {', '.join(sorted(_ALLOWED_EXTENSIONS))})"
260 )
261 return file_path
262
263 def _resolve_under_dir(root_dir: Path, rel_path: str) -> Path:
264 file_path = root_dir / rel_path

Callers

nothing calls this directly

Calls 3

_normalize_relative_pathFunction · 0.85
_has_parent_referenceFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected