refactor: reduce complexity of execute_impl in upload_pipeline_artifact.rs#1625
Merged
jamesadevine merged 1 commit intoJul 22, 2026
Conversation
…ct.rs Extract six focused helpers from the 383-line execute_impl: - resolve_effective_build_id: resolve build ID from request or BUILD_BUILDID - resolve_final_artifact_name: all allowlist/name-prefix/extension checks - resolve_staged_file: canonicalize, bounds-check, size/dir checks - resolve_ado_context: extract org_url/project/project_id/token/container_id - upload_file_to_container: Step 1 HTTP PUT to the build container - associate_artifact_with_build: Step 2 HTTP POST to associate artifact record The remaining execute_impl is now 85 lines with a clear sequential narrative: resolve IDs → validate names → validate staged file → dry-run → verify hash → resolve context → dedupe check → upload → associate → record dedupe key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jamesadevine
marked this pull request as ready for review
July 22, 2026 20:54
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.
What was complex
execute_implinsrc/safe_outputs/upload_pipeline_artifact.rswas a single 383-line function with 33 branch points spanning six distinct phases:Each phase had multiple early-return guard clauses nested inside the single function, making it hard to understand the overall flow and difficult to test individual phases in isolation.
What changed
Six focused helper functions were extracted:
resolve_effective_build_idBUILD_BUILDIDresolve_final_artifact_nameExecutionResult::failureresolve_staged_fileStagedFileInfoor failureresolve_ado_contextArtifactAdoContextupload_file_to_containerassociate_artifact_with_buildThe remaining
execute_implis now 85 lines with a clear sequential narrative: resolve IDs → validate names → validate staged file → dry-run check → verify hash → resolve ADO context → dedupe check → upload → associate → record dedupe key.Two data-carrying structs (
ArtifactAdoContext,StagedFileInfo) were introduced to avoid passing many individual parameters between the helpers.Verification
cargo test)cargo clippy --all-targets --all-featuresis cleanWarning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.