Skip to content

Conversation

@Iamrodos
Copy link
Contributor

Fixes #163 - Handle HTTP 451 (DMCA takedown) responses

When encountering a 451 due to DMCA'd repositories, log a warning with the DMCA notice URL and continue with other repositories, instead of terminating with the error.

To avoid multiple messages and repeated wasted requests for each component (eg issues, prs) the tool raises an exception so multiple activities for the repo can be skipped to move onto the next one.

Example of skipping DMCA'd repo 127MU/phigros-html5

github-backup 127MU -t TOKEN --output-directory /private/tmp/test_dmca_v2 --issues --pulls --milestones --labels --releases --fork
2025-11-29T09:10:57.332: Create output directory /private/tmp/test_dmca_v2
2025-11-29T09:10:57.332: Backing up user 127MU to /private/tmp/test_dmca_v2
2025-11-29T09:10:57.844: Retrieving repositories
2025-11-29T09:10:58.271: Backing up repositories

2025-11-29T09:10:58.271: Retrieving 127MU/127MU issues
...
2025-11-29T09:10:59.153: Saving 0 issues to disk

2025-11-29T09:10:59.931: Retrieving 127MU/Mining issues
...
2025-11-29T09:11:01.111: Saving 0 releases to disk

2025-11-29T09:11:01.111: Retrieving 127MU/Mining issues
2025-11-29T09:11:01.112: Requesting https://api.github.com/repos/127MU/Mining/issues?per_page=100&filter=all&state=open
...
2025-11-29T09:11:03.950: Saving 0 releases to disk

2025-11-29T09:11:03.951: Retrieving 127MU/phigros-html5 issues
2025-11-29T09:11:03.951: Requesting https://api.github.com/repos/127MU/phigros-html5/issues?per_page=100&filter=all&state=open
2025-11-29T09:11:04.324: Repository 127MU/phigros-html5 is unavailable (HTTP 451)
2025-11-29T09:11:04.324: DMCA notice: https://github.com/github/dmca/blob/master/2024/11/2024-11-04-source-code.md
2025-11-29T09:11:04.324: Skipping remaining resources for 127MU/phigros-html5

2025-11-29T09:11:04.324: Retrieving 127MU/RIP-PrivateMod issues
...
2025-11-29T09:11:07.533: Saving 0 releases to disk

2025-11-29T09:11:07.533: Retrieving 127MU/YunzaiBotHelper issues
...
2025-11-29T09:11:10.353: Saving 0 releases to disk

Exit code is 0.

Added pytest on the 451 logic (written by AI).

Side note

DMCA'd repositories will have an empty directory created (e.g., repositories/phigros-html5/issues/). This occurs because directory creation happens before the first API request. It would be a bigger refactor to change the order of when the directory is created. Considered writing an UNAVAILABLE.txt to the directory, but that gets messy as a repo can be un-DMA'd (e.g. youtube-dl) and a subsequent run might work and populate the directories.

Log a warning and the link to the DMCA notice. Continue backing up
other repositories instead of crashing.

Closes josegonzalez#163
@josegonzalez josegonzalez merged commit 995b7ed into josegonzalez:master Nov 28, 2025
10 checks passed
@Iamrodos Iamrodos deleted the http-451 branch November 29, 2025 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exits when finding DMCA'd repos – API request returned HTTP 451: Unavailable for Legal Reasons

2 participants