-
Notifications
You must be signed in to change notification settings - Fork 40
STJ-23: BUGFIX: deprecation_tracker breaking with unknown keywords #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ab4fc9a
to
1107bc0
Compare
end | ||
|
||
def warn(*messages, uplevel: nil, category: nil) | ||
def warn(*messages, uplevel: nil, category: nil, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method override now explicitly accepts both known (uplevel
, category
) and unknown (**kwargs
) keyword arguments. This makes it compatible with upstream libraries (like sass-embedded
) that may pass unexpected keys.
lib/deprecation_tracker.rb
Outdated
else | ||
super | ||
begin | ||
super(*messages, uplevel: uplevel, category: category, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This forwards all keyword arguments — both expected (uplevel
, category
) and any extras like :deprecation
, :span
, etc. — to super
. If the superclass doesn't accept extra keywords, we fall back to known ones to avoid breaking.
lib/deprecation_tracker.rb
Outdated
super | ||
begin | ||
super(*messages, uplevel: uplevel, category: category, **kwargs) | ||
rescue ArgumentError => e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some logging implementations (e.g., in native gems) may not accept arbitrary keyword args. This fallback ensures compatibility by only passing the known, expected keys.
@julioalucero I'd like to merge #156 first to check from ruby 2.3+ to make sure your changes are compatible with older rubies first. And please do not use the |
1107bc0
to
5e1ea9a
Compare
Moving here #157 |
STJ-23: BUGFIX: deprecation_tracker breaking with unknown keywords
Description
BUGFIX: Prevent DeprecationTracker from crashing when receiving unknown keyword arguments.
In certain environments (e.g. when using sass-embedded), the warn method receives unexpected keyword arguments such as :deprecation, :span, or :stack. Previously, these unrecognized keywords would raise an ArgumentError and interrupt execution. This patch safely handles unknown keyword arguments while preserving known ones.
Motivation and Context
Fixes #152 — DeprecationTracker was breaking during setup in projects using sass-embedded due to unhandled keyword arguments in warn.
This update ensures that warn forwards all known and unknown keyword arguments safely to super, and gracefully falls back to known keywords if the parent method does not accept extras.
How Has This Been Tested?
Screenshots:
I will abide by the code of conduct