refactor: reduce complexity of execute_impl in upload_build_attachment.rs#1656
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
…t.rs Extract five focused helpers from the 345-line monolithic execute_impl: - resolve_effective_build_id: build-ID match/validation logic - resolve_final_artifact_name: name-prefix application + charset/allowlist checks - resolve_attachment_type: operator config resolution + charset validation - resolve_staged_file: path canonicalization, directory guard, size integrity check - resolve_ado_attachment_url: ADO context collection + timeline-attachment URL construction - upload_attachment_to_ado: HTTP PUT + response parsing (AttachmentUploadParams struct) execute_impl body shrinks from 345 lines to ~100 lines of clear sequential phases. All 2580 unit tests pass; clippy is clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
UploadBuildAttachmentResult::execute_implwas a 345-line monolithic async function with 6 separate inline phases, each with its own error-return paths and nesting depth up to 5 levels.What was complex
The function sequentially handled:
Each phase had 2–4 early-return failure paths, making the function hard to read and test in isolation.
What changed
Extracted five focused helpers:
resolve_effective_build_idOk(Ok(id))/Ok(Err(failure))/Err(infra)resolve_final_artifact_nameresolve_attachment_typeresolve_staged_fileresolve_ado_attachment_urlupload_attachment_to_adoAttachmentUploadParamsstruct to avoid clippytoo_many_arguments)execute_implbody shrinks from 345 lines to ~100 lines of clear sequential phases.Verification
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.