INNER CODE UNIT · Python
handle_get_file_contents
nolabs-ai/deepfabric · tools-sdk/components/github/app.py:169
def handle_get_file_contents(args: dict) -> dict: # noqa: PLR0911
"""Get contents of a file or directory from a repository."""
owner = args.get("owner")
repo = args.get("repo")
path = args.get("path", "")
ref = args.get("ref", "")
if not owner or not repo:
return {"success": False, "result": "Missing required: owner, repo", "error_type": "InvalidArguments"}
# Validate repo access
allowed, error = validate_repo_access(owner, repo)
if not allowed:
return {"success": False, "result": error, "error_type": "RepoNotAllowed"}
try:
endpoint = f"/repos/{owner}/{repo}/contents/{path}"
if ref: