Skip to content

[21143] Fix ServiceNow MCP Tool Bug#21184

Merged
GTFalcao merged 5 commits into
masterfrom
21143-servicenow-bug-fix
Jun 23, 2026
Merged

[21143] Fix ServiceNow MCP Tool Bug#21184
GTFalcao merged 5 commits into
masterfrom
21143-servicenow-bug-fix

Conversation

@vetrivigneshwaran

@vetrivigneshwaran vetrivigneshwaran commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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

  • All components updated in this PR had their version updated (0.0.1 for new ones)
  • The app updated in this PR had its package.json's version updated

New app

If this is a new app, please submit an app integration request - the PR will only be reviewed after the app is integrated.

  • The app updated in this PR is already 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.

  • I have addressed or acknowledged all of CodeRabbit's review comments

Summary by CodeRabbit

  • Refactor
    • Updated the ServiceNow “get current user” action to use improved request handling and streamlined retrieval of the current user and their details.
    • Adjusted how the instance URL is derived to ensure consistent results across environments.
  • Versioning
    • Bumped the ServiceNow component version to 0.10.2 and the action version to 0.0.2.

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.
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
pipedream-docs-redirect-do-not-edit Ignored Ignored Jun 23, 2026 4:31pm

Request Review

@pipedream-component-development

Copy link
Copy Markdown
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development

Copy link
Copy Markdown
Collaborator

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:

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The get-current-user action removes its direct axios dependency and refactors both API calls to use this.servicenow._makeRequest(). The session lookup now uses the relative URL /ui/user/current_user and reads sys_id directly from sessionInfo?.sys_id. The user details request calls _makeRequest with /table/sys_user/${userSysId} and uses the helper response directly without .result unwrapping. The instance URL is now built from $auth.instance_name. Action version bumps to 0.0.2 and package version to 0.10.2.

Changes

get-current-user action refactor

Layer / File(s) Summary
Replace axios with _makeRequest and update field access
components/servicenow/actions/get-current-user/get-current-user.mjs, components/servicenow/package.json
Removes the axios import and both direct axios calls, substituting _makeRequest with relative URLs /ui/user/current_user and /table/sys_user/${userSysId}. Updates sys_id extraction to read directly from sessionInfo?.sys_id, removes .result unwrapping on the user fetch response, reconstructs the instance URL from $auth.instance_name, and bumps action version to 0.0.2 and package version to 0.10.2.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references the specific bug being fixed (ServiceNow MCP Tool Bug) and the issue ID, accurately summarizing the main purpose of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR description is comprehensive with clear issue explanation, root cause analysis, fix details, and completed versioning checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 21143-servicenow-bug-fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 | 🔴 Critical

Response structure is already unwrapped by _makeRequest()—line 23 is accessing a non-existent .result property.

The _makeRequest() method in servicenow.app.mjs (line 127) returns response.result, meaning it unwraps the API response before returning it. Line 23 then incorrectly tries to access sessionInfo?.result?.sys_id, but sessionInfo is already the unwrapped object. This causes userSysId to be undefined, 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 .result prefix, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 99ba6a6 and 9de0e8c.

📒 Files selected for processing (2)
  • components/servicenow/actions/get-current-user/get-current-user.mjs
  • components/servicenow/package.json

@GTFalcao GTFalcao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done with the changes

@GTFalcao GTFalcao moved this from Ready for PR Review to Changes Required in Component (Source and Action) Backlog Jun 22, 2026
@GTFalcao GTFalcao moved this from Changes Required to Ready for QA in Component (Source and Action) Backlog Jun 23, 2026
@GTFalcao GTFalcao merged commit aebb392 into master Jun 23, 2026
9 checks passed
@GTFalcao GTFalcao deleted the 21143-servicenow-bug-fix branch June 23, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ServiceNow MCP Tool Bug

4 participants