Skip to content

fix(auth): validate options parameter in ServiceAccountCredentials.make_creds - #588

Merged
aandreassa merged 1 commit into
mainfrom
clarify-json-key-io
Jul 27, 2026
Merged

fix(auth): validate options parameter in ServiceAccountCredentials.make_creds#588
aandreassa merged 1 commit into
mainfrom
clarify-json-key-io

Conversation

@aandreassa

@aandreassa aandreassa commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
  • Warn on unrecognized options passed to ServiceAccountCredentials.make_creds.
  • Raise InitializationError when required credential fields or valid json_key_io objects are missing.
  • Fix unescape(nil) bug to handle nil inputs safely.
  • Update make_creds docstring to document all supported options.

Fixes #482
Fixes #544

@aandreassa
aandreassa force-pushed the clarify-json-key-io branch from f083f0b to b174fc5 Compare July 23, 2026 21:05
@aandreassa aandreassa changed the title fix(auth): validate parameters in ServiceAccountCredentials.make_creds fix(auth): validate JSON parameter in ServiceAccountCredentials.make_creds Jul 23, 2026
…AccountCredentials.make_creds

- Warn on unrecognized options passed to `ServiceAccountCredentials.make_creds`.
- Raise `InitializationError` when required credential fields or valid `json_key_io` objects are missing.
- Fix `unescape(nil)` bug to handle `nil` inputs safely.
- Update `make_creds` docstring to document all supported options.

Fixes #482
Fixes #544
@aandreassa
aandreassa force-pushed the clarify-json-key-io branch from b174fc5 to 767dcb9 Compare July 24, 2026 00:07
@aandreassa aandreassa changed the title fix(auth): validate JSON parameter in ServiceAccountCredentials.make_creds fix(auth): validate options parameter in ServiceAccountCredentials.make_creds Jul 24, 2026
@aandreassa
aandreassa marked this pull request as ready for review July 24, 2026 00:15
@aandreassa
aandreassa requested a review from a team as a code owner July 24, 2026 00:15
Comment thread spec/googleauth/service_account_spec.rb
#
# @param options [Hash] The options hash to validate.
def self.validate_make_creds_options options
return unless options.is_a? Hash

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: based on the feedback from issue #482 would it make sense to add a warn or raise an error on some of the input types? There seemed to be confusion around String vs IO input for json_key and json_key_io so I'm wondering if we can clarify the typing a bit more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is a warn just down below on using incorrect entry names (most common mistake). I also defined the types in the docstrings.

json_key_io.respond_to? :read above is to check IO vs String, which will raise an error.

Do you think that's sufficient?

@aandreassa
aandreassa requested a review from a team July 27, 2026 20:27
@aandreassa
aandreassa merged commit 3da9927 into main Jul 27, 2026
20 checks passed
@aandreassa
aandreassa deleted the clarify-json-key-io branch July 27, 2026 23:56
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.

Auth Error Highly Misleading googleauth-1.11.0/lib/googleauth/service_account.rb:87:in unescape': undefined method gsub' for nil:NilClass

2 participants