Add cached diff-scan polling support to DiffScans.get - #97
Closed
lelia wants to merge 1 commit into
Closed
Conversation
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>
|
🚀 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.dev1 |
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.
DiffScans.getnow accepts optional query params — notablycached=true— and surfaces the API's202 Acceptedprocessing status as{"status": "processing", "id": ...}instead of treating it as an error. This lets clients pollGET /orgs/{org_slug}/diff-scans/{diff_scan_id}?cached=truewith short bounded requests until the computed diff is ready (HTTP 200). Also fixes list-valued query params (e.g.committers) increate_from_repo/create_from_idsto encode as repeated params (urlencode(doseq=True)).Version bumped to 3.4.0.
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 intermittentConnectionResetError(104, 'Connection reset by peer')failures on the final comparison step.The companion CLI PR (SocketDev/socket-python-cli) switches the comparison to
diffscans.create_from_ids+ pollingdiffscans.get(..., params={"cached": "true"}), which needs this SDK support.omit_license_details/omit_unchangedpassthrough 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.getnow 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 ascommittersare now encoded correctly indiffscans.create_from_repo/create_from_ids.