Skip to content

fix(hapi): Handle routes registered with an array of methods - #25482

Closed
itisrmk wants to merge 2 commits into
getsentry:developfrom
itisrmk:cursor/hapi-array-method-693d
Closed

itisrmk wants to merge 2 commits into
getsentry:developfrom
itisrmk:cursor/hapi-array-method-693d

Conversation

@itisrmk

@itisrmk itisrmk commented Oct 18, 2026 •

Copy link
Copy Markdown

Hapi accepts server.route({ method }) as a string or an array of strings, and only expands an array into one route per method after instrumentation has already wrapped the handler. The wrapper closed over that array, so with traceLifecycle: 'static' it called route.method.toUpperCase() and threw, turning the request into a 500. The same array was also stored on http.request.method.

The wrapped handler now reads the single method Hapi has resolved on the request and uses that uppercase value for the static span name and http.request.method. Routes registered with a string method are unchanged.

Tests: added unit coverage in packages/server-utils and an array-method case to the Hapi node integration suite (ESM and CJS). yarn lint and yarn test pass.

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request.

Fixes #25481

This change was prepared with AI assistance.

Fixes getsentry#25481

Co-Authored-By: Cursor <cursoragent@cursor.com>

Co-authored-by: Rahul Kashyap <itisrmk@users.noreply.github.com>
@itisrmk
itisrmk requested a review from a team as a code owner October 18, 2026 00:51
@itisrmk
itisrmk requested review from JPeer264 and mydea and removed request for a team October 18, 2026 00:51
@github-actions github-actions Bot added the external PR from an external contributor label Oct 18, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 57293ad. Configure here.

Comment thread dev-packages/node-integration-tests/suites/tracing/hapi/test.ts
Co-Authored-By: Cursor <cursoragent@cursor.com>

Co-authored-by: Rahul Kashyap <itisrmk@users.noreply.github.com>
@s1gr1d

s1gr1d commented Oct 19, 2026

Copy link
Copy Markdown
Member

Thanks a lot for the fix, @itisrmk! We went with #25527, which takes the method from the request in all cases, also for string and '*' routes.

We added you as a co-author and in the CHANGELOG. Closing this in favour of #25527.

@s1gr1d s1gr1d closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hapi: route.method.toUpperCase is not a function for routes registered with an array of methods

3 participants