Skip to content

fix(processors/github_metadata): handle ChunkedEncodingError and other network exceptions#149

Closed
Rabenherz112 wants to merge 1 commit into
nodiscc:masterfrom
Rabenherz112:fix-network-exception-error
Closed

fix(processors/github_metadata): handle ChunkedEncodingError and other network exceptions#149
Rabenherz112 wants to merge 1 commit into
nodiscc:masterfrom
Rabenherz112:fix-network-exception-error

Conversation

@Rabenherz112

@Rabenherz112 Rabenherz112 commented Nov 1, 2025

Copy link
Copy Markdown
Contributor

closes #148

Okay, so correct me if I'm wrong, but as far as I understand it from looking at the requests library docs, ChunkedEncodingError is a server-side issue that happens when the server says it sends chunks, but doesn't.

Interestingly, when I test this on my own system, I don't get ChunkedEncodingError, like never. Instead I get a ton of 502 errors, which the code already handles properly with retries (since I had those issues when I built it). But apparently in production/CI environments (or maybe just under different network conditions or regions? not really sure how you / and the CI encounters them but I don't), the server problem shows up as ChunkedEncodingError instead of a 502 status code (but this seems also rather rarely? I only saw this happen in the awesome-selfhosted CI once when you manually executed it).

As far as I can tell, I can't really tweak the code to prevent ChunkedEncodingError, since it's a server-side issue (i.e. GitHub doing GitHub things with the API), so all we can do is handle it gracefully. The best way to fix this, which I can think of, is to treat ChunkedEncodingError (and similar network exceptions like ConnectionError and Timeout) the same way we already treat HTTP 502/503/504/429 errors, since it's a similar issue:

  1. First retry: wait and try the same batch again
  2. Second+ retry: split the batch into smaller chunks to reduce the response size, and wait longer to avoid rate limiting
  3. If it still fails after max_retries, error out and log it

I tried to reproduce the issue, by running the metadata update process manually with different sleep times multiple times, on multiple days, but I never got the ChunkedEncodingError. For that reason it would be great if you could give it a try, and see if it works for you. Again, when I run it, I just get this kind of output (I really get a lot of 502's):

Output when running the metadata update process manually
INFO:main.py: running step update all metadata from Github API
INFO:github_metadata.py: updating software data from Github API
INFO:github_metadata.py: Processing batch 1/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 2/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 2 with same size
INFO:github_metadata.py: Processing batch 2/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 3/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 3 with same size
INFO:github_metadata.py: Processing batch 3/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 4/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 4 with same size
INFO:github_metadata.py: Processing batch 4/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 5/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 6/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 7/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 7 with same size
INFO:github_metadata.py: Processing batch 7/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 8/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 8 with same size
INFO:github_metadata.py: Processing batch 8/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 9/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 10/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 11/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 12/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 13/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 14/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 14 with same size
INFO:github_metadata.py: Processing batch 14/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 15/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 15 with same size
INFO:github_metadata.py: Processing batch 15/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 16/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 16 with same size
INFO:github_metadata.py: Processing batch 16/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 17/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 18/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 19/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 20/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 21/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 22/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 23/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 24/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 25/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 26/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 27/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 27 with same size
INFO:github_metadata.py: Processing batch 27/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 28/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 29/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 30/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 31/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 32/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 33/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 34/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 35/36 (batch size: 30)
WARNING:github_metadata.py: GraphQL request failed with status code 502 (attempt 1/3), waiting 60 seconds
INFO:github_metadata.py: Retrying batch 35 with same size
INFO:github_metadata.py: Processing batch 35/36 (batch size: 30)
INFO:github_metadata.py: Processing batch 36/36 (batch size: 11)
ERROR:github_metadata.py: There were errors during processing

Edit: I'm not even sure we want to catch this. This appears to be a one-off error. So not sure whether it's worth adding 100 lines of code for something that happened until now only once and seems also to have a really low chance.

@nodiscc nodiscc self-requested a review November 4, 2025 20:09
@nodiscc nodiscc self-assigned this Dec 1, 2025
@Rabenherz112

Copy link
Copy Markdown
Contributor Author

Is now integrated as well in #152

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.

processors/github_metadata: sometimes fails with ChunkedEncodingError

2 participants