Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/googleauth/user_authorizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_credentials user_id, scope = nil
scope: data["scope"] || @scope,
access_token: data["access_token"],
refresh_token: data["refresh_token"],
expires_at: data.fetch("expiration_time_millis", 0) / 1000
expires_at: (data.fetch("expiration_time_millis") || 0) / 1000

@robertvoinescu-work robertvoinescu-work Oct 13, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using fetch without a default will raise a KeyError if the key missing, could we instead do:

expires_at:    (data["expiration_time_millis"] || 0) / 1000

Furthermore, could you also add a couple of unit tests covering both the nil and missing key cases in spec/googleauth/user_authorizer_spec.rb? That way we can avoid regressions.

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.

This is what I was concerned about as well.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Oh yes, agreed, I didn't "see" that the default was being removed, just saw the coalescing bit.

)
scope ||= @scope
return monitor_credentials user_id, credentials if credentials.includes_scope? scope
Expand Down
Loading