Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where service blocks were missing from the internal API due to a type mismatch between keys. The issue occurred because Formula#to_hash_with_variations returns different key types (symbols vs strings) depending on whether the API is being used or not, causing Service.from_hash to fail when looking for string keys in a hash with symbol keys.
Changes:
- Add
.deep_stringify_keyscall ingenerate_formula_struct_hashto ensure consistent string keys throughout the hash - Update
Service.replace_placeholdersto acceptPathnameobjects in addition to strings and convert them to strings before processing
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/service.rb | Updated type signature and implementation of replace_placeholders to handle Pathname values by converting them to strings |
| Library/Homebrew/api/formula/formula_struct_generator.rb | Added deep_stringify_keys call after merge_variations to ensure all hash keys are consistently strings before processing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
@Rylan12 CI failure looks relatively legit here? |
Member
Author
|
Oof yeah, I think so. Will look into fixing that later tonight |
64d4f82 to
404e8e1
Compare
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.
Service blocks were accidentally left out of the internal API due to a type mismatch.
Formula#to_hash_with_variationsreturns different types based on whether running viaHOMEBREW_NO_INSTALL_FROM_APIor not. If using the API, it returns JSON-ified values (i.e. everything is a string), but if not using the API, it returns a mix of symbols, pathnames, etc. This ultimately resulted in a mismatch whereHomebrew::Service::from_hashattempted to search for the key"run"and turned up blank, because what it was looking for was listed under:run.To solve this, let's stringify the keys before processing the variations hash into a
FormulaStruct, that way keys throughout the hash are consistently strings. Note that values can still be non-strings, so I had to make another small change to processPathnames correctly.Unfortunately, this will require re-installing any affected formulae (once the API is regenerated) to actually install the service files.