Skip to content

Add cached diff-scan polling support to DiffScans.get - #99

Open
lelia wants to merge 2 commits into
mainfrom
lelia/diff-scan-polling
Open

Add cached diff-scan polling support to DiffScans.get#99
lelia wants to merge 2 commits into
mainfrom
lelia/diff-scan-polling

Conversation

@lelia

@lelia lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

DiffScans.get now accepts optional query params — notably cached=true — and surfaces the API's 202 Accepted processing status as {"status": "processing", "id": ...} instead of treating it as an error. This lets clients poll GET /orgs/{org_slug}/diff-scans/{diff_scan_id}?cached=true with short bounded requests until the computed diff is ready (HTTP 200). Also fixes list-valued query params (e.g. committers) in create_from_repo/create_from_ids to encode as repeated params (urlencode(doseq=True)).

Why?

The Python CLI's scan comparison currently uses fullscans.stream_diff, which holds one HTTP connection open — fully idle — while the backend computes the diff. Network middleboxes with TCP idle timeouts (notably Azure NAT gateways, 4-minute default) kill that connection with a RST, surfacing as intermittent ConnectionResetError(104, 'Connection reset by peer') failures on the final comparison step for scans run on self-hosted CI runners.

The companion CLI PR switches the comparison to diffscans.create_from_ids + polling diffscans.get(..., params={"cached": "true"}), which needs this SDK support. omit_license_details/omit_unchanged passthrough lets the CLI keep the lean-response behavior from CE-224.

New unit tests cover the query-string passthrough, the 202 processing status (with and without a response body), and repeated-param encoding. python -m pytest tests/unit: 126 passed, 1 skipped.

Public Changelog

diffscans.get now supports query parameters (cached, omit_unchanged, omit_license_details) and returns a {"status": "processing"} result for HTTP 202, enabling clients to poll for diff-scan results instead of holding a long-lived connection open. List-valued query params such as committers are now encoded correctly in diffscans.create_from_repo/create_from_ids.

Refs CE-354

DiffScans.get now accepts optional query params (cached, omit_unchanged,
omit_license_details) and returns a {"status": "processing", "id": ...}
dict on HTTP 202 instead of logging an error, so clients can poll
GET /orgs/{org}/diff-scans/{id}?cached=true until the computed diff is
ready rather than holding a single idle connection open while the
backend computes (which idle-timeout middleboxes like Azure NAT
gateways kill after ~4 minutes).

Also encode list-valued query params (e.g. committers) as repeated
params in create_from_repo/create_from_ids via urlencode(doseq=True).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketdev==3.4.0.dev5

@lelia
lelia marked this pull request as ready for review August 5, 2026 04:11
@lelia
lelia requested a review from a team as a code owner August 5, 2026 04:11
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 04:11 — with GitHub Actions Inactive
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 04:23 — with GitHub Actions Inactive
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