Raise ArgumentError when nil settings passed to some methods#790
Raise ArgumentError when nil settings passed to some methods#790alstrocrack wants to merge 10 commits into
ArgumentError when nil settings passed to some methods#790Conversation
|
@alstrocrack, can you extend the review to other classes? Please add guardrails as well to avoid the NoMethodError errors, thanks! |
| # @param settings [OneLogin::RubySaml::Settings|nil] Toolkit settings | ||
| # @return [String] The deflated and encoded SAML Message (encoded if the compression is requested) | ||
| # | ||
| def encode_raw_saml(saml, settings) |
There was a problem hiding this comment.
I found this dead code. What do you think about me deleting this code because I thought it was related to these changes? As far as I checked, this code isn’t called from anywhere and is a private method.
|
I added some changes to this PR. I searched for incorrect comments regarding I thought I also found some other places where similar Could you check these changes again? |
ArgumentError when nil settings passed to some methods
Status
READY
Migrations
NO
Description
Several methods across
OneLogin::RubySaml::Authrequest,Logoutrequest,SloLogoutresponse, andMetadataacceptednilas theirsettingsargument according to YARD comments ([OneLogin::RubySaml::Settings|nil]), but in practice passingnilcauses aNoMethodErrorimmediately when the method tries to call methods onsettings.This PR:
ArgumentErrorguard at the top of each affected public method, providing a clear error message instead of a crypticNoMethodError@paramannotations to remove|nil, accurately reflecting thatnilis not a valid valueencode_raw_samlfromSamlMessageArgumentErrorwas chosen over the library's customSettingErrorbecause passingnilis a caller-side programming error (wrong argument), whereasSettingErroris reserved for cases where a settings object exists but contains invalid or missing configuration values.Related PRs
N/A
Todos
Deploy Notes
N/A
Steps to Test or Reproduce
N/A
Impacted Areas in Application
Authrequest#create,#create_params,#create_authentication_xml_docLogoutrequest#create,#create_params,#create_logout_request_xml_docSloLogoutresponse#create,#create_params,#create_logout_response_xml_docMetadata#generate