Skip to content

[refactor] Duplicated pip/pip3 executable resolution fallback in pip_validation.go #71315

Not planned

Description

@github-actions

Summary

Sampled analysis (rotation slice pkg/workflow 455/636, 2026-10-23, full-rotation bound 804 days) reviewed 4 files / 10 functions (417 source lines) from pkg/workflow and pkg/cli. One significant duplication was found; this is a sampled snapshot, not a claim of full-package or full-repository coverage.

Finding

pkg/workflow/pip_validation.go contains the same "resolve pip, fall back to pip3" sequence written out twice:

  • validatePipPackages (lines 120-130):

pipPath, err := fileutil.ResolveExecutablePath("pip")
if err != nil {
// Try pip3 as fallback
pipPath, err = fileutil.ResolveExecutablePath("pip3")
if err != nil {
pipValidationLog.Print("pip command not found, skipping validation")
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("pip command not found - skipping pip package validation. Install Python/pip for full validation"))
return nil
}
pipValidationLog.Print("Using pip3 command for validation")
}

  • validateUvPackages, in its uv-not-found branch (lines 191-211):

pipPath, pipErr := fileutil.ResolveExecutablePath("pip")
if pipErr != nil {
// Try pip3 as fallback
var pip3Err error
pipPath, pip3Err = fileutil.ResolveExecutablePath("pip3")
if pip3Err != nil {
pipValidationLog.Print("Neither uv nor pip commands found, cannot validate")
combinedErr := errors.Join(
fmt.Errorf("pip: %w", pipErr),
fmt.Errorf("pip3: %w", pip3Err),
)
return NewOperationError(
"validate", "uv packages", "", combinedErr,
"Install uv or pip to enable package validation:...",
)
}
pipValidationLog.Print("Using pip3 for validation")
}

Both blocks perform the identical two-step fileutil.ResolveExecutablePath("pip") then fileutil.ResolveExecutablePath("pip3") resolution with the same log-message pattern ("Using pip3 ... for validation"). Only the failure handling differs: validatePipPackages logs a warning and returns nil (soft-skip), while validateUvPackages builds a combined error with install instructions (hard-fail).

Proposed refactoring

Extract the shared resolution step into a small helper in pip_validation.go, e.g. resolvePipOrPip3() (path string, pipErr, pip3Err error), that returns both underlying errors (or the resolved path) and lets each caller keep its own distinct failure-handling policy (soft-skip vs. hard error with install instructions). This removes the duplicated two-call resolution and logging sequence while preserving each caller current error-handling behavior exactly.

Preservation risks

  • validatePipPackages skip-and-warn behavior and validateUvPackages combined-error/install-instructions behavior must both be preserved unchanged; only the resolution step should be shared.
  • validateUvPackages is longer than the packet 80-line/4KiB excerpt cap and was supplied truncated past this point (truncated: true); the remainder of that function was not reviewed and no claims are made about it beyond the quoted block.
  • The corresponding pkg/workflow/pip_validation_wasm.go stub file (where validatePipPackages/validateUvPackages are no-ops under the wasm build tag) is an intentional platform-split pattern, not a duplication finding, and should remain untouched.

Scope note

This issue reflects a sampled daily rotation slice (pkg/workflow 455/636, pkg/cli 456/557) covering 10 functions across 4 files, not a review of either package or the repository as a whole.

Generated by 🔧 Semantic Function Refactoring · claude · sonnet50 · ~48 AIC · ⌖ ~25 AIC · ⊞ 5.2K · ◷

  • expires on Oct 24, 2026, 6:41 PM UTC-08:00

Activity

  1. github-actions commented on Oct 23, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~2 AIC · ⊞ 13.1K · ◷

  2. github-actions commented on Oct 24, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~1 AIC · ⊞ 12.9K · ◷

  3. github-actions commented on Oct 24, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~1 AIC · ⊞ 12.5K · ◷

  4. github-actions commented on Oct 25, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~1 AIC · ⊞ 12.5K · ◷

  5. github-actions commented on Oct 25, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-25T02:41:22.907Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions