Skip to content

v3.3.0 — the cap was checked after the body was already in memory

Choose a tag to compare

@fatherlinux fatherlinux released this 09 Nov 05:57
· 12 commits to main since this release
eecda68

RT #1601, the fleet's outbound HTTP contract. Three read paths here — the API, a content download and the OAuth token exchange — and all three had the same defect.

  • The cap was checked after the body was in memory. Each path compared len(response.content) > MAX_RESPONSE_SIZE once the whole body had arrived. All three now stream, measured before each chunk is copied in, because aiter_bytes() promises nothing about chunk size: one chunk can be the whole body. The token exchange gets its own, smaller cap — a token response is a handful of JSON fields, and anything page-sized answering on that URL is not a token.
  • Requests were nameless. All three paths now send mcp-pcloud-crunchtools/<version> (+<repo>), the version read from installed package metadata so it cannot drift from pyproject.toml.
  • Malformed JSON from listfolder blamed the parser for what is usually a challenge page. Errors now name the method, the full requested URL, the status, the content-type and a bounded snippet.

A pCloud content URL is signed, so naming it is only safe because the signature comes out first: userinfo is dropped and credential-shaped query parameters are replaced. The token exchange quotes no body at all — it is the one endpoint whose body is a credential.

Two things review caught that are worth recording:

  • Replacing response.text lost the declared charset, so a Latin-1 document would have come back with replacement characters where its accents were. It decodes with response.encoding now.
  • The old suite patched httpx.AsyncClient.get and httpx.Client.post. A patch on a method the code no longer calls does not fail — it lets the test reach the real network, which is how three tests were briefly talking to api.pcloud.com. The suite rides a MockTransport now, which has no live socket to fall through to.

Constitution pin v1.31.0 → v1.36.0.