docs: describe save_file's real sequence in the Python README - #12
Merged
Merged
Conversation
Step 1 claimed the default branch's tip SHA is always looked up; save_file only reads it when the per-file branch does not exist yet. Step 3 omitted the read of the file's SHA on the branch, which is also why a save cannot create a new file (a 404 before anything is committed). The module docstring carried the same step list and is corrected alongside. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Self-review rubric (head
Judgment call flagged for a human reader:
Out-of-diff observation: the README's Errors section still overstates the contract ("Everything that stopped an edit from landing raises This review comment 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
Stage A documentation-accuracy sweep. The numbered "What a save actually does" list in
python/README.mdwas checked againstGitHubDocsClient.save_fileand two claims did not hold:save_filereads it only when the per-file branch does not exist yet (get_ref_sha(default_branch)sits inside theif branch_sha is None:block). The tip lookup is moved into step 2, where it actually happens.get_file(path, ref=branch)read that supplies the SHA for the PUT. It is now stated, together with its consequence: a save edits a file that already exists. For a path with no file on the branch, the read 404s andsave_fileraisesGitHubDocsErrorwith.status404 before any commit — leaving behind any per-file branch that step 2 just created. This was confirmed by runningsave_file("new.md", …)against a patchedurlopen: the request sequence stopped atGET …/contents/new.md?ref=docs-edit/new.md, and the resulting error carried status 404.The module docstring in
python/src/github_docs/client.pycarried the same step list and is corrected in the same way. That is a docstring-only change:_redact, theAuthorizationheader and error construction are untouched.The sweep also found that the README's Errors section ("Everything that stopped an edit from landing raises
GitHubDocsError") does not hold for a read timeout or a non-JSON 2xx body. Because that is a code bug (the README describes the intended contract), it is filed as #11 and not changed here.Half:
python/only.No tracking issue: this is drift found during the Stage A sweep.
Skipped issues
Test plan
save_fileand confirmed with a patched-urlopenprobepython (3.9–3.13)green on the PR head. The only code change is a docstring, but local verification was UNVERIFIED: the sandbox interpreter is Python 3.8, below the 3.9 floor, so the CI matrix is the anchorjslegs green (not touched)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