Skip to content
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

fix(jmespath): refactor custom function introspection to work with minification #2384

Conversation

dreamorosi
Copy link
Contributor

Description of your changes

This PR fixes a bug that caused JMESPath custom functions to fail to be detected and throw a runtime error when running on minified functions.

The previous logic relied on the name of the class (via prototype.constructor.name) which caused it to fail when the code is minified since entities are aliased to use shorter names.

The new logic introduced in this PR uses an identity check (value instanceof Class) which minification-proof since even when aliased both classes will still maintain their inheritance.

Related issues, RFCs

Issue number: #2383

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my change is effective and works
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Apr 17, 2024
@dreamorosi dreamorosi requested review from a team as code owners April 17, 2024 09:18
@dreamorosi dreamorosi linked an issue Apr 17, 2024 that may be closed by this pull request
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Apr 17, 2024
@github-actions github-actions bot added the bug Something isn't working label Apr 17, 2024
@dreamorosi dreamorosi requested a review from am29d April 17, 2024 09:31
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@am29d am29d left a comment

Choose a reason for hiding this comment

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

great catch, we might need to inspect other places where we use prototype checks, we might discover more over time.

@am29d am29d merged commit 21ecc4f into main Apr 17, 2024
11 checks passed
@am29d am29d deleted the 2383-bug-jmespath-custom-functions-introspection-breaks-when-minifying branch April 17, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/M PR between 30-99 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: jmespath custom functions introspection breaks when minifying
2 participants