Skip to content

fix(jsm): improve create request error handling, add form-based submission support#4066

Merged
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/jsm-create-request-fix
Apr 9, 2026
Merged

fix(jsm): improve create request error handling, add form-based submission support#4066
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/jsm-create-request-fix

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Fix JSM create_request swallowing Atlassian error messages (now surfaces actual errorMessage from API)
  • Add form-based request type support (formAnswers param) for JSM create_request
  • Add Atlassian error extractor to error-extractors registry
  • Move rarely-used create_request fields to advanced mode
  • Make summary optional at tool level to support form-only requests (block UI still enforces it for basic mode)

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 9, 2026

PR Summary

Medium Risk
Medium risk because it changes jsm_create_request input validation and request payload construction (including new formAnswers path), which could affect request creation behavior across integrations.

Overview
Improves jsm_create_request to support form-based Jira Service Management request types by adding an optional formAnswers parameter and allowing create operations when either summary or formAnswers is provided.

Fixes error reporting for JSM API failures by parsing and surfacing Atlassian errorMessage (with better logging) instead of returning only generic HTTP status text.

Updates the block UI/tool schemas and docs to reflect the new parameter, makes summary optional (required unless using formAnswers), moves rarely used create-request fields to advanced mode, and adds an atlassian-errors entry to the shared error-extractor registry.

Reviewed by Cursor Bugbot for commit 3019fd0. Configure here.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 9, 2026 5:03am

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR improves JSM create_request error surfacing by extracting Atlassian errorMessage into a shared parseJsmErrorMessage helper (covering both POST and GET error paths), adds form-based request support via formAnswers, and registers a new atlassian-errors extractor. The prior-review duplicate-extraction concern has been addressed.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style/UX suggestions that don't affect correctness.

The duplicate error-extraction concern from the prior review has been cleanly resolved with parseJsmErrorMessage. The formAnswers flow is correctly threaded through types, tool, block params, and route. The two remaining comments are UX polish (missing required indicator on summary subBlock) and a misleading fallthrough error on the internal route — neither blocks production usage.

apps/sim/blocks/blocks/jira_service_management.ts (summary required indicator), apps/sim/app/api/tools/jsm/request/route.ts (isCreateOperation fallthrough message)

Vulnerabilities

No security concerns identified. The route uses checkInternalAuth, all IDs are validated with validateAlphanumericId/validateJiraCloudId before use, and formAnswers is forwarded as a structured object (not interpolated into queries or commands). Error messages from Atlassian are extracted and returned but not reflected into sensitive contexts.

Important Files Changed

Filename Overview
apps/sim/app/api/tools/jsm/request/route.ts Adds parseJsmErrorMessage helper (addressing prior review) and formAnswers support; isCreateOperation condition updated; requestFieldValues merge logic is correct but the fallback path produces a misleading error when serviceDeskId+requestTypeId are given without summary or formAnswers.
apps/sim/blocks/blocks/jira_service_management.ts Adds formAnswers subBlock, JSON-parsing guards for both requestFieldValues and formAnswers, and summary/formAnswers co-validation in params; summary subBlock is not marked required in the block config despite PR description claiming basic-mode enforcement.
apps/sim/tools/jsm/create_request.ts summary changed to optional, formAnswers added; tool body correctly forwards both to the route; transformResponse unchanged and still surfaces error from route.
apps/sim/tools/error-extractors.ts New atlassian-errors extractor added first in the registry and exported via ErrorExtractorId; useful for Atlassian tools that don't pre-transform errors at the route level.
apps/sim/tools/jsm/types.ts summary made optional, formAnswers added as optional Record<string, unknown>; type changes are consistent with tool and route.
apps/docs/content/docs/en/tools/jira_service_management.mdx Docs updated to reflect summary optionality and new formAnswers parameter; accurate and complete.

Sequence Diagram

sequenceDiagram
    participant Block as JSM Block (UI)
    participant Params as params()
    participant Tool as jsmCreateRequestTool
    participant Route as /api/tools/jsm/request
    participant Atlassian as Atlassian JSM API

    Block->>Params: operation=create_request, summary?, formAnswers? (string)
    alt missing summary AND formAnswers
        Params-->>Block: throw Error("Summary is required...")
    end
    Params->>Params: JSON.parse(requestFieldValues)
    Params->>Params: JSON.parse(formAnswers)
    Params->>Tool: { summary?, description?, requestFieldValues?, formAnswers? }
    Tool->>Route: POST { serviceDeskId, requestTypeId, summary?, formAnswers?, ... }
    Route->>Route: isCreateOperation = serviceDeskId && requestTypeId && (summary || formAnswers)
    alt isCreateOperation
        Route->>Route: build requestBody (merge requestFieldValues + summary/description)
        opt formAnswers present
            Route->>Route: requestBody.form = { answers: formAnswers }
        end
        Route->>Atlassian: POST /request
        alt API error
            Atlassian-->>Route: { errorMessage: ... }
            Route->>Route: parseJsmErrorMessage() → JSM API error: ...
            Route-->>Tool: { error: JSM API error: ... }
        else success
            Atlassian-->>Route: { issueKey, issueId, ... }
            Route-->>Tool: { success: true, output: { issueKey, ... } }
        end
    else not isCreateOperation
        Route->>Route: fall through to GET path (issueIdOrKey required)
    end
    Tool-->>Block: result
Loading

Reviews (3): Last reviewed commit: "fix(jsm): include description in request..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

Both findings from the Greptile summary addressed in 724f9fd:

  1. summary required in advanced mode — removed required: true from the subBlock entirely. The tools.config.params validation (!params.summary && !params.formAnswers) already enforces that at least one is provided, so the form-only flow now works in advanced mode.

  2. JSON.parse without error handling — wrapped both requestFieldValues and formAnswers parsing in try/catch with user-friendly error messages.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Description silently dropped in form-only request mode
    • Updated the condition on line 94 to check for description presence, ensuring it's included in requestFieldValues even when summary is not provided.

Create PR

Or push these changes by commenting:

@cursor push da3de167c3
Preview (da3de167c3)
diff --git a/apps/sim/app/api/tools/jsm/request/route.ts b/apps/sim/app/api/tools/jsm/request/route.ts
--- a/apps/sim/app/api/tools/jsm/request/route.ts
+++ b/apps/sim/app/api/tools/jsm/request/route.ts
@@ -91,7 +91,7 @@
         requestTypeId,
       }
 
-      if (summary || requestFieldValues) {
+      if (summary || description || requestFieldValues) {
         const fieldValues =
           requestFieldValues && typeof requestFieldValues === 'object'
             ? {

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3019fd0. Configure here.

@waleedlatif1 waleedlatif1 merged commit db23078 into staging Apr 9, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/jsm-create-request-fix branch April 9, 2026 05:17
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.

1 participant