Skip to content

Pass raw request bodies to requests as data - #29

Merged
tomchop merged 1 commit into
mainfrom
fix/do-request-body
Oct 2, 2026
Merged

tomchop merged 1 commit into
mainfrom
fix/do-request-body

Conversation

@tomchop

@tomchop tomchop commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

do_request forwarded raw bodies to requests under the keyword body. requests has no such argument, so any call with a raw body raised TypeError: Session.request() got an unexpected keyword argument 'body' before anything was sent. upload_dfiq_archive is the only method that passes one, so it could never succeed.

What changed

  • do_request passes raw bodies as data, the name requests uses.
  • Unit test. test_upload_dfiq_archive mocked Session.post, which accepts any keyword, so it passed with the bug in place. It now mocks Session.send, one layer down. That way the real Session.request builds the request from what do_request passes, and the test checks that the archive bytes reach the request body. On main it fails with the TypeError above. The archive is now a real temporary file rather than a patched builtins.open, because requests runs inside the test and may open files of its own, such as ~/.netrc.
  • e2e test. test_upload_dfiq_archive uploads a one-scenario archive to a live Yeti and looks the scenario up afterwards. Nothing in tests/e2e.py exercised the upload before.

Verification

Unit and type checks, run the way CI does after poetry install --no-root:

  • poetry run python -m unittest tests/api.py: 39 passed. On main's yeti/api.py, the updated test errors with the TypeError.
  • poetry run pyrefly check: 0 errors

tests/e2e.py against a local Yeti built from main plus yeti-platform/yeti#1403, using API key auth: 15 passed, including the new test, which errors on main with the TypeError.

Release

No version bump: 2.4.0, from #28, isn't released yet, and this ships with it.

do_request forwarded raw bodies to requests under the keyword `body`, which
requests doesn't accept, so any call with a raw body raised TypeError before
anything was sent. upload_dfiq_archive is the only such caller, and could not
succeed.

The unit test mocked Session.post, which accepts any keyword. It now mocks
Session.send, so requests builds the request from the arguments do_request
passes, and it checks that the archive bytes reach the request body. A new e2e
test uploads an archive to a live Yeti.
@tomchop
tomchop merged commit 2f6f6ba into main Oct 2, 2026
3 checks passed
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.

1 participant