diff --git a/.autograde/upload_metadata.py b/.autograde/upload_metadata.py index 89dec80..8341ac5 100644 --- a/.autograde/upload_metadata.py +++ b/.autograde/upload_metadata.py @@ -98,8 +98,15 @@ def main() -> int: try: with urllib.request.urlopen(get_req) as resp: existing_file = json.loads(resp.read().decode()) - sha = existing_file.get("sha") - print(f"File exists, updating (sha: {sha})") + # API may return a list (directory contents) or dict (single file) + if isinstance(existing_file, dict): + sha = existing_file.get("sha") + print(f"File exists, updating (sha: {sha})") + elif isinstance(existing_file, list): + # Response is a directory listing, file doesn't exist at this exact path + print(f"Path is a directory or file not found in expected format") + else: + print(f"Unexpected response type: {type(existing_file)}") except urllib.error.HTTPError as e: if e.code != 404: print(f"Error checking file existence: {e}", file=sys.stderr)