Repository navigation
Keep http.client errors and deep JSON from escaping the trace read - #262
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 100,000-deep body raises it on 3.10 but parses on 3.15, so the depth-based case was interpreter-dependent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review: no blocking issues found. The
This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
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.
Summary
fleetweather.fetch_windowturnedHTTPError,URLError,OSErrorandValueErrorinto aWeatherUnavailablereason, buturlopenpasseshttp.client.HTTPExceptionthrough unwrapped. A garbled status line (BadStatusLine), a truncated body (IncompleteRead) or aGARDENER_HUB_TRACE_URLwith a non-numeric port (InvalidURL, whichConfig.problemdoes not reject) therefore escaped.json.loadson a deeply nested body can raiseRecursionErrorrather thanValueError(it does on Python 3.10, the declared floor), so that escaped too. All four now become a short reason (trace unreachable (<type>)/trace's answer is not JSON), matching whathub.py's_requestandUserAuthClient._callalready catch after Report every unusable hub as a HubError instead of a traceback #244/Treat every unusable UserAuth answer as an outage #247. TheRequestconstruction was moved inside thetryfor the same reason_requestgives.gardener hub city-still, which the gateway's digest timer runs, has no backstop aroundForecaster.sample, so any of these printed a traceback and failed the still. The module docstring says a trace failure "never fails/api/cityor the still"./api/citythe route'sexcept Exceptionkept the response at 200, butForecaster.windowonly records its cache timestamp after aWeatherUnavailable. So every poll from every viewer re-read a misbehaving trace, againstCACHE_SECONDS's "two viewers must not mean two reads", and the status shown was a bare exception type.hub city-still --weather-samplegiven a file deep enough to raiseRecursionErrornow exits 2 with its one-line error instead of a traceback.docs/TESTING.md'stest_fleetweather.pyparagraph names the new cases.The problem was not tracked in an issue; it was found during this cycle's triage scan. The four open issues (#248, #154, #100, #94) all wait on a maintainer decision.
Test plan
python3 -m compileall gardener teststest_http_client_failures_and_deep_nesting_are_reasons_not_crashesintests/test_fleetweather.py: stub openers raisingBadStatusLine,IncompleteReadandInvalidURL, each checked for its exact reason and for the credential's absence, plusjson.loadspatched to raiseRecursionError. The first push used a real 100,000-deep body for the last case instead. It passed on 3.10 but failed on 3.15, which parses that depth without aRecursionError, so the case was made deterministic incdda42e.test_a_deeply_nested_sample_file_is_exit_2_not_a_traceback: exit 2 on every interpreter. It reaches the newRecursionErrorbranch only where the interpreter raises it (3.10); elsewhereparse_samplerefuses the parsed list.gardener/fleetweather.pyandgardener/cli.pyrestored fromorigin/main, and the removal asserted (grep -cprinted0for both files), all four cases escapedfetch_windowas their raw exception types. Once the files were restored, all four came back asWeatherUnavailableandgit status --porcelainwas empty.cdda42eis the anchor of record:test (3.10),test (3.x)(bothtests/and theintegration/offline tier),city-still,fleetcityandgarden3dall pass. Locally the sandboxpython3is 3.8, belowrequires-python, so the cases were exercised directly againstgardener.fleetweatherrather than through the test module.dispatch.py,dev_loop.pyor prompt template is touched, so no manual dispatch verification is required, and the "Safety model impact" checklist does not apply.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson