You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compare the base API, not to_s, when refreshing a mounted app (#2788)
`refresh_already_mounted` deduplicates endpoints for the "same" mounted
app by comparing `endpoint.mounted_app.to_s == app.to_s`. That only works
by accident: `mount` turns every mounted Grape API into a throwaway
`mount_instance` (a fresh `Class.new(@base_parent)` per mount), so two
mounts of the same API are distinct objects, and `Grape::API::Instance`
delegates `to_s` to its `@base` (the original API). The comparison is
really "same base API", done through a string proxy -- brittle (two APIs
that happen to share a name collide) and unclear.
Expose the base API via a reader and compare it by identity instead. Plain
Rack apps have no base and are mounted as-is, so they fall back to object
identity.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@
17
17
*[#2792](https://github.com/ruby-grape/grape/pull/2792): Move `Grape::Path` to `Grape::Router::Pattern::Path` and add a `Grape::Router::Pattern.build` factory (`Grape::Path` kept as a deprecated constant) - [@ericproulx](https://github.com/ericproulx).
18
18
*[#2785](https://github.com/ruby-grape/grape/pull/2785): Make route `params` a first-class endpoint input and split `Grape::Router::Route#params` into `#params` (declared definitions) and `#params_for(input)` (extracted values) - [@ericproulx](https://github.com/ericproulx).
19
19
*[#2786](https://github.com/ruby-grape/grape/pull/2786): Make route `requirements` and `anchor` explicit keyword arguments and first-class endpoint inputs instead of opaque `route_options` keys - [@ericproulx](https://github.com/ericproulx).
20
+
*[#2788](https://github.com/ruby-grape/grape/pull/2788): Compare the base API instead of `to_s` when refreshing a mounted app - [@ericproulx](https://github.com/ericproulx).
0 commit comments