[21143] Fix ServiceNow MCP Tool Bug#21184
Conversation
Issue: servicenow-get-current-user action crashes with TypeError: this.servicenow.baseUrl is not a function Summary The ServiceNow MCP tool servicenow-get-current-user (action version 0.0.1) fails on every invocation with a TypeError, before any network call is made. All other ServiceNow actions work fine on the same connected account. Root cause: The action called this.servicenow.baseUrl() and this.servicenow.authHeaders() — neither of which exist on the published servicenow.app.mjs. The app only exposes _makeRequest(), which handles auth and the base URL internally. Fix: The action now uses the same _makeRequest pattern as every other working ServiceNow action (e.g., search-records-by-keyword), eliminating the TypeError on every invocation. Version bumped 0.0.1 → 0.0.2, package 0.10.1 → 0.10.2.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
📝 WalkthroughWalkthroughThe Changesget-current-user action refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/servicenow/actions/get-current-user/get-current-user.mjs (1)
18-49:⚠️ Potential issue | 🔴 CriticalResponse structure is already unwrapped by
_makeRequest()—line 23 is accessing a non-existent.resultproperty.The
_makeRequest()method inservicenow.app.mjs(line 127) returnsresponse.result, meaning it unwraps the API response before returning it. Line 23 then incorrectly tries to accesssessionInfo?.result?.sys_id, butsessionInfois already the unwrapped object. This causesuserSysIdto beundefined, triggering the error on line 26 every time the action runs.Line 23 should be:
const userSysId = sessionInfo?.sys_id;Lines 37–48 are correct in accessing
user.name,user.user_name, etc. directly without a.resultprefix, since the second_makeRequest()call also returns an already-unwrapped result.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@components/servicenow/actions/get-current-user/get-current-user.mjs` around lines 18 - 49, The `_makeRequest()` method already unwraps the API response by returning the result property, so the sessionInfo variable contains the already-unwrapped object. On line 23, remove the `.result` property accessor when retrieving the sys_id, changing `sessionInfo?.result?.sys_id` to `sessionInfo?.sys_id` to correctly access the sys_id from the unwrapped response object returned by the first `_makeRequest()` call.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@components/servicenow/actions/get-current-user/get-current-user.mjs`:
- Around line 18-49: The `_makeRequest()` method already unwraps the API
response by returning the result property, so the sessionInfo variable contains
the already-unwrapped object. On line 23, remove the `.result` property accessor
when retrieving the sys_id, changing `sessionInfo?.result?.sys_id` to
`sessionInfo?.sys_id` to correctly access the sys_id from the unwrapped response
object returned by the first `_makeRequest()` call.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b52b052f-2fe8-46ad-b558-bcb21a6ff708
📒 Files selected for processing (2)
components/servicenow/actions/get-current-user/get-current-user.mjscomponents/servicenow/package.json
GTFalcao
left a comment
There was a problem hiding this comment.
Can you confirm if this needs to be addressed? I saw the CodeRabbit comment after I had approved before
| }); | ||
|
|
||
| const userSysId = sessionInfo.result?.user_sys_id; | ||
| const userSysId = sessionInfo?.result?.sys_id; |
There was a problem hiding this comment.
There's a CodeRabbit comment about _makeRequest already unwrapping .result from the response, which is true - perhaps this should not be using .result here but looking up the field name directly.
There was a problem hiding this comment.
Done with the changes
Issue: servicenow-get-current-user action crashes with TypeError: this.servicenow.baseUrl is not a function Summary The ServiceNow MCP tool servicenow-get-current-user (action version 0.0.1) fails on every invocation with a TypeError, before any network call is made. All other ServiceNow actions work fine on the same connected account.
Root cause: The action called this.servicenow.baseUrl() and this.servicenow.authHeaders() — neither of which exist on the published servicenow.app.mjs. The app only exposes _makeRequest(), which handles auth and the base URL internally.
Fix: The action now uses the same _makeRequest pattern as every other working ServiceNow action (e.g., search-records-by-keyword), eliminating the TypeError on every invocation. Version bumped 0.0.1 → 0.0.2, package 0.10.1 → 0.10.2.
Resolves: #21143
Checklist
Please check the following items before your PR can be reviewed:
Versioning
0.0.1for new ones)package.json's version updatedNew app
If this is a new app, please submit an app integration request - the PR will only be reviewed after the app is integrated.
CodeRabbit review
After the PR is opened, and if new changes are pushed, CodeRabbit will automatically review it. Do not 'mark as resolved' CodeRabbit's comments, but reply to them instead, whether you agree (and update the PR accordingly) or disagree.
Summary by CodeRabbit