Skip to content

Commit

Permalink
Ignore 404 error in get_remote_file_content() as that means file_path…
Browse files Browse the repository at this point in the history
… is not correct due to hallucination
  • Loading branch information
hiroshinishio committed Jul 8, 2024
1 parent 52be714 commit 54d7d13
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion services/github/github_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,14 @@ def get_remote_file_content(
response: requests.Response = requests.get(
url=url, headers=headers, timeout=TIMEOUT_IN_SECONDS
)

# If 404 error, return early. Otherwise, raise a HTTPError
if response.status_code != 404:
return f"{get_remote_file_content.__name__} encountered an HTTPError: 404 Client Error: Not Found for url: {url}"
response.raise_for_status()
response_json = response.json()

# file_path is expected to be a file path, but it can be a directory path due to AI's volatility. See Example2 at https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28
response_json = response.json()
if response_json["type"] == "dir":
entries: list[dict[str, str, int, dict]] = response_json["entries"]
contents: list[str] = []
Expand Down

0 comments on commit 54d7d13

Please sign in to comment.