Repository navigation
Conversation
…th the price download TreasuryDirect rebuilt FedInvest. The CSV download now answers 403 unless the request carries the session cookie and the _csrf token of the price form, so every treasury_prices request failed. Read the form first and post the download on the same session. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
treasury_pricesfails for every request: TreasuryDirect answers the FedInvest CSV download with 403.TreasuryDirect rebuilt FedInvest. The download (
securityPriceDetail) is now refused unless the request carries the session cookie and the_csrftoken of the price form (selectSecurityPriceDate). The cookies are set for thewwwhost. The page is still public; no account is involved.Change
UsTreasuryPricesFetcher.extract_datareads the form, takes the token, and posts the download on the same session. It uses the existingget_requests_sessionandmake_requesthelpers; nothing new is added to the utilities.Tests
test_treasury_models.py: the payload test now checks the form request, the token in the payload, and that both requests share one session; a new test covers a form with no token. The HTTP-error and encoding tests go through the same two-step fake.test_us_treasury_fetchers.py::test_treasury_prices_fetcher: cassette re-recorded for the two requests, with the cookie and token values replaced by placeholders.government_ussuite: 3,261 pass.ruff checkandruff format --checkclean on the touched files.Not changed
transform_datareads the CSV withheader=0, and the file has no header row, so the first security of the day is dropped. That is the existing behaviour and is left for a separate change.🤖 Generated with Claude Code