fecfile
fecfile copied to clipboard
Follow redirects
https://github.com/esonderegger/fecfile/blob/dc923ed0a688586070033e8115a709f9c60cfe1d/fecfile/init.py#L125
It looks like the code only allows for redirects on 404
s but doesn't have a condition for 300
s
Issue
I keep getting a FilingUnavailableError
:
[ERROR] FilingUnavailableError: The requested FEC file number (FEC-1305714) is unavailable.
Traceback (most recent call last):
File "/var/task/src/FECFileLoader.py", line 312, in lambdaHandler
options={'filter_itemizations': [FILING_TYPE]}):
File "/var/task/fecfile/__init__.py", line 134, in iter_http
raise FilingUnavailableError({'file_number': file_number})
But when I curl
that filing I get a 307 and 200 so it seems the filing is available:
> curl -IL http://docquery.fec.gov/dcdev/posted/1305714.fec
HTTP/1.1 307 Temporary Redirect
Cache-Control: no-cache
Content-length: 0
Location: https://docquery.fec.gov/dcdev/posted/1305714.fec
HTTP/1.1 200 OK
Server: Apache
Last-Modified: Sun, 20 Jan 2019 20:49:01 GMT
Cache-Control: max-age=21600
Expires: Wed, 02 Sep 2020 20:43:10 GMT
Content-Type: mime.types:application/fecprn
Content-Length: 705
Accept-Ranges: bytes
Date: Wed, 02 Sep 2020 14:43:10 GMT
X-Varnish: 111590184
Age: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=63072000
Thanks for submitting this issue!
Being able to follow 3xx redirects sounds like a good idea for this library, since the FEC might some day migrate their URLs.
That said, I wasn't able to reproduce this issue. I think this may have been fixed in https://github.com/esonderegger/fecfile/commit/dc923ed0a688586070033e8115a709f9c60cfe1d
Could you please verify that you are running version 0.6.3 or the current master
branch. If so, what is a file number where you are seeing a redirect?
You might be right, I'm having trouble reproducing this locally. I have a few lambdas using this library and that error has been an intermittent problem. I'm using library version 0.6.3
but I'm hoping the extra error info from #25 helps elucidate the cause. 🤞