spreedly / gala

Ruby library for decrypting Apple Pay payment tokens
MIT License
41 stars 24 forks source link

Use `fetch` to require hash keys #18

Closed soberstadt closed 5 months ago

soberstadt commented 2 years ago

We ran into an issue while refactoring the code around our usage of Gala and ended up passing corrupted hashes into Gala::PaymentToken.new this resulted in exceptions, but obtuse errors like NoMethodError: undefined method 'unpack1' for nil:NilClass. This patch changes the hash digging to use fetch, which will raise KeyErrors instead, making it more clear there was corruption.

soberstadt commented 5 months ago

If you ever want to merge this, you can re-open it 😃