Skip to content

Fix memory leak when using recognize_path inside Grape::API #2567

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

Merged
merged 2 commits into from
May 20, 2025

Conversation

ericproulx
Copy link
Contributor

Fix #2566

@grape-bot
Copy link

2 Warnings
⚠️ There're library changes, but not tests. That's OK as long as you're refactoring existing code.
⚠️ Unless you're refactoring existing code or improving documentation, please update CHANGELOG.md.

Here's an example of a CHANGELOG.md entry:

* [#2567](https://github.com/ruby-grape/grape/pull/2567): Fix memory leak when using recognize_path inside grape::api - [@ericproulx](https://github.com/ericproulx).

Generated by 🚫 Danger

@ericproulx ericproulx requested a review from Copilot May 20, 2025 19:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR prevents overriding recognize_path in Grape::API to address a memory leak when using that method.

  • Added recognize_path to the NON_OVERRIDABLE list.
  • Ensures recognize_path cannot be redefined on API classes.
Comments suppressed due to low confidence (2)

lib/grape/api.rb:8

  • Add a test case to verify that recognize_path cannot be overridden on an API subclass, ensuring the memory leak fix is properly enforced.
    NON_OVERRIDABLE = %i[call call! configuration compile! inherited recognize_path].freeze

lib/grape/api.rb:8

  • [nitpick] Update related documentation or comments to mention that recognize_path is protected from overrides, so users understand why it's included in NON_OVERRIDABLE.
    NON_OVERRIDABLE = %i[call call! configuration compile! inherited recognize_path].freeze

@ericproulx ericproulx marked this pull request as ready for review May 20, 2025 19:18
@ericproulx ericproulx mentioned this pull request May 20, 2025
@dblock dblock merged commit 14d9f9d into ruby-grape:master May 20, 2025
63 checks passed
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.

Memory leak
3 participants