wwzeng1 / landing-page

1 stars 1 forks source link

Sweep: Fix this bug #381

Closed kevinlu1248 closed 1 month ago

kevinlu1248 commented 1 month ago

Details

sweepai/core/sweep_bot.py in safe_decode at line 130

            blob = repo.get_git_blob(contents.sha)
            try:
                return base64.b64decode(blob.content).decode(chardet.detect(base64.b64decode(blob.content))['encoding'])
            except UnicodeDecodeError:
                return read_file_with_fallback_encodings(base64.b64decode(blob.content))
        return contents.decoded_content.decode("utf-8")
    except GithubException as e:
        raise e
    except Exception as e:
        raise e

Here's the outer stack

sweepai/core/review_utils.py in get_pr_changes at line 101

            except GithubException:
                old_code = ""
        if file.status == "removed":
            new_code = ""
        else:
            new_code = safe_decode(repo=repo, path=file.filename, ref=head_sha)
        status = file.status
        pr_change = PRChange(
                file_name=file_name,
                diff=diff,
                old_code=old_code,

We should just return none for bad encodings. Then skip the file in the review loop for these bad encodings.