From dce220e51863ca23772b3ef2ab5c1e24799f3931 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Wed, 3 Sep 2025 12:34:06 -0400 Subject: [PATCH] Cask::Audit: fix `key not found: :latest` error `Cask::Audit.audit_livecheck_version` can raise a `key not found: :latest` error when a hash from livecheck's `latest_version` method doesn't have a `:latest` value. This error means that livecheck was unable to identify the latest upstream version but it can only be understood if the reader knows how this audit is implemented (and it may also depend on knowing the structure of livecheck's `latest_version` hash). Without that knowledge, the error doesn't make it clear which audit is failing and why. This addresses the issue by using `nil` as the default value for this `fetch` call and accounting for a `nil` `latest_version` value. This allows the audit to surface the usual "Version '1.2.3' differs from '' retrieved by livecheck" failure, which makes it more clear that livecheck isn't returning a version. --- Library/Homebrew/cask/audit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 8883e6c8bd..7437fa252d 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -755,9 +755,9 @@ module Cask latest_version = Homebrew::Livecheck.latest_version( cask, referenced_formula_or_cask: referenced_cask, - )&.fetch(:latest) + )&.fetch(:latest, nil) - return :auto_detected if cask.version.to_s == latest_version.to_s + return :auto_detected if latest_version && (cask.version.to_s == latest_version.to_s) add_error "Version '#{cask.version}' differs from '#{latest_version}' retrieved by livecheck."