Skip to content

Conversation

@Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Dec 30, 2025

Fixes #21342
Follow-up to #21333

If we are uninstalling a cask that had saved its JSON data instead of its ruby source, there is a chance that this data is an older format and it may be missing certain keys. In all places that are applicable, let's use safe-navigation operators to fall-back to default values if needed.

Copilot AI review requested due to automatic review settings December 30, 2025 16:50
Copy link
Contributor

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 addresses an issue where uninstalling casks that have saved JSON data in an older format could fail due to missing keys. The changes add safe navigation operators (&.) to prevent NoMethodError exceptions when certain fields are absent from the stored JSON data.

Key Changes:

  • Added safe navigation operators to handle potentially missing JSON keys in the cask struct generation
  • Applied defensive programming to container, depends_on, rename, and url_specs fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@p-linnane p-linnane added this pull request to the merge queue Dec 31, 2025
Merged via the queue into main with commit 9580057 Dec 31, 2025
37 checks passed
@p-linnane p-linnane deleted the fix-cask-struct branch December 31, 2025 00:46
@MikeMcQuaid
Copy link
Member

Thanks @Rylan12!

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.

Uninstall causes undefined method 'map' for nil

4 participants