Repository navigation
fix: check the steps of builds - #107
Conversation
- Signing: only GitHub's 204 counts as a triggered dispatch; any other response is logged with its status and takes the existing failure path (500, build back to its previous status, token kept, retried with the pod's next report). Passwords of dockerhub_token are split at the first colon only. - Updater: build pods get REPOSITORYID, and the updater reports to that repository, so any repository.id_length works; pods without it fall back to the first 6 characters, as before. - Clones are named after the last part of the repository's URL, or "repository" if that isn't a plain file name, instead of the fifth part of the URL split at "/" (a 500 for other URL forms). The pod's name comes from the build ID, not from its file's path. Docs: deployment guide (signing failures and retries, REPOSITORYID, clone directory). Closes #94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review findings: a repository named config.json (or *.yaml) would be cloned into the path of the build's own Docker configuration (or pod file), failing every build; such names now get "repository". Tests check that the repository ID reaches create_build and the pod file, and that a URL of another form (a local path) is cloned. The docs describe the clone directory where cloning is described, and the signing retries in a paragraph of their own. Refs #94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round-2 review: the docs presented every URL that Git can clone as supported, including local paths. Name remote URLs of other forms instead; wrap the paragraph on failed completions, and give the new Args entries the types their siblings have. Refs #94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideImplementationCarry the repository ID from build registration into the generated pod so the updater can report builds to repositories with any configured ID length, while preserving the legacy fallback for existing pods.
Derive safe clone directory names from varied repository URL forms, and pass the build ID explicitly rather than inferring it from the deployment file path.
Treat only GitHub's 204 response as an accepted signing dispatch, and split Docker Hub credentials only at the username-password separator.
DocumentationExplain GitHub response handling and the retry behavior when signing dispatches fail.
Document repository ID propagation and the fallback for pods created by earlier versions.
Describe the clone directory naming rule and its support for remote URL forms.
TestsTest signing response validation and Docker Hub passwords containing colons, plus mock responses that distinguish GitHub by host.
Test repository ID plumbing from build startup through the generated pod and updater report URL.
Test clone naming for varied URL forms, safe fallbacks, and cloning from a local path.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #107 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 18 +1
Lines 1517 1545 +28
=========================================
+ Hits 1517 1545 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
CodeQL (py/incomplete-url-substring-sanitization): the request mocks told GitHub apart by a substring of the URL. Compare the host instead. Refs #94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Linked issuesChecked at commit b2153a9 #94 fix: check the steps of builds · 3 of 3 met
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pubgrade/modules/endpoints/builds.py" line_range="1331-1337" />
<code_context>
raise InternalServerError from None
+ # GitHub accepts a dispatch with 204; anything else (e.g., a 401 for a
+ # wrong token, a 404 for a wrong `gh_action_path`) triggers no workflow
+ if response.status_code != 204:
+ logger.error(
+ "Triggering the signing of %s failed: GitHub answered %s",
+ push_tag,
+ response.status_code,
+ )
+ raise InternalServerError
</code_context>
<issue_to_address>
**Overlapping reports corrupt completion**
When two completion callbacks for the same build overlap, `build_completed` lets both callbacks pass the token check and update the build to `SUCCEEDED`, so both can dispatch signing and notify subscriptions, duplicating workflows and notifications. If both dispatches fail, the rollback race leaves the build appearing successful even though signing never started.
Atomically claim completion before dispatching side effects, and make rollback conditional on that claim.
</issue_to_address>
### Comment 2
<location path="pubgrade/modules/endpoints/builds.py" line_range="1331-1337" />
<code_context>
raise InternalServerError from None
+ # GitHub accepts a dispatch with 204; anything else (e.g., a 401 for a
+ # wrong token, a 404 for a wrong `gh_action_path`) triggers no workflow
+ if response.status_code != 204:
+ logger.error(
+ "Triggering the signing of %s failed: GitHub answered %s",
+ push_tag,
+ response.status_code,
+ )
+ raise InternalServerError
</code_context>
<issue_to_address>
**Rejected dispatches retry without backoff**
When gitHub continues rejecting dispatches, for example because the token or action path is invalid, `build_completed` restores the build's previous status after this rejection, and the updater reports the still-succeeded pod again every five seconds. A persistent GitHub rejection therefore generates repeated dispatch requests and error logs for every affected build until the setting is fixed or the build is canceled.
Add a bounded or backoff-based retry policy for persistently rejected dispatches.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and a non-204 GitHub response puts the build back into a state that causes another signing dispatch, so a dispatch that took effect despite an error response could launch duplicate external workflows; reverting cannot undo workflows already launched. The new repository ID also determines where a build report is sent, so a propagation error could update the wrong repository’s build record.
Blocking findings: pubgrade/modules/endpoints/builds.py:1337, pubgrade/modules/endpoints/builds.py:1337
Summary
Fixes the gaps of the build path listed in #94 (only with
endpoints.builds.enabled), before the 0.2.0 tag:204counts as triggered. Any other answer (e.g.,401for a wrongGH_ACCESS_TOKEN,404for a wronggh_action_path,422) is logged with its status and takes the existing failure path: a 500, the build back to its previous status, files, pod and registry token kept, so the pod's next report (5 seconds later) triggers the signing again. Subscribers are no longer notified of an image that is never published.repository.id_length: build pods getREPOSITORYID, and the updater reports to that repository. Pods without it (created by earlier versions) fall back to the first 6 characters, as before.clone_directory(): the last part of the URL's path (or of an scp-like address), without.git. Names that aren't plain file names (..,-repo, empty) or that would collide with the build's own files (config.json,*.yaml) getrepository. Before,repo_url.split("/")[4]gave a 500 for URLs of other forms.create_deployment_YAML()takes the build ID instead ofsplit("/")[2]of its file's path, which assumed a base directory one level deep.dockerhub_tokenis split at the first:only, so passwords may contain colons.Docs:
docs/deployment.md(log messages, signing failures and their retries,REPOSITORYID, the clone's directory).Closes #94
Verification
pytest --cov: 715 passed, coverage 100%MONGODB_TEST_URI=… pytest tests/integrationagainst MongoDB 7.0: 45 passedruff check,ruff format --check,mypy: clean;mkdocs build --strict: cleantest_trigger_signing_image_accepted,test_trigger_signing_image_rejected(200, 401, 404, 422, 500),test_clone_directory,test_git_clone_and_checkout_other_url,test_create_deployment_yaml_names,test_report_build_repository_id; the repository ID is asserted fromstart_build()to the pod fileReview
Two rounds (adversarial and quality reviewer). Fixed: a repository named
config.jsonwould have been cloned onto the build's Docker configuration; tests for the repository ID's way to the pod and for a URL of another form; docs placement and wrapping; docstring style.Declined review findings
Back-off for a signing that GitHub keeps refusing (low): a refused dispatch is requested again every 5 seconds per build, until the setting is fixed or the build is canceled. fix: check the steps of builds #94 asks for exactly the existing failure path (back to the previous status, retried with the next report); a back-off or marking 4xx answers as
FAILEDchanges the retry design and fits a separate issue. The behaviour and the log message are documented.Validate repository URLs (low, not new): repository URLs aren't checked when repositories are registered or updated (see the comment in
repositories.py), so a local path orfile://URL can be cloned, as with the oldsplit("/")too. Restricting them to remote schemes is new behaviour for the registration API and fits a separate issue; the docs now speak of remote URLs only, and builds are documented as for trusted repositories only.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Harden build creation and completion reporting across signing failures, configurable repository IDs, and varied repository and credential formats.
Bug Fixes:
Enhancements:
Documentation:
Tests: