Skip to content

Conversation

carlocab
Copy link
Member

@carlocab carlocab commented Jul 31, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

cmd can be a Pathname (see the type signature), but ohai seems to
expect only Strings now (because it calls Formatter.headline, which
only accepts Strings).

While we're here, let's assert that cmd exists whenever it is a
Pathname, to avoid passing arguments like bin/"cmd --version" (which
is not a valid Pathname).

See, for example, Homebrew/homebrew-core#231882.

`cmd` can be a `Pathname` (see the type signature), but `ohai` seems to
expect only `String`s now.

While we're here, let's assert that `cmd` exists whenever it is a
`Pathname`, to avoid passing arguments like `bin/"cmd --version"` (which
is not a valid `Pathname`).

See, for example, Homebrew/homebrew-core#231882.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a typechecking error in the shell_output and pipe_output methods within formula_assertions.rb. The issue arises because ohai expects only String arguments, but these methods accept both Pathname and String types for the cmd parameter.

  • Converts cmd to string before passing to ohai using cmd.to_s
  • Adds validation to ensure Pathname arguments actually exist on the filesystem
  • Prevents invalid usage patterns like bin/"cmd --version" which creates invalid pathnames

@carlocab carlocab enabled auto-merge July 31, 2025 22:04
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@carlocab carlocab added this pull request to the merge queue Aug 1, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 1, 2025
@carlocab carlocab added this pull request to the merge queue Aug 1, 2025
Merged via the queue into main with commit f5bddac Aug 1, 2025
36 checks passed
@carlocab carlocab deleted the assertions-typecheck branch August 1, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants