pipedream icon indicating copy to clipboard operation
pipedream copied to clipboard

jira — Auto-resolve cloudId internally to remove it as a required agent input

Open s0s0physm opened this issue 8 months ago • 3 comments

Problem

Every Jira action requires cloudId as an input prop because it's part of the base URL for every API call (https://api.atlassian.com/ex/jira/{cloudId}/rest/api/3). The cloud instance is selected during the account connection flow, but the site grant access is managed on the Atlassian side. The auth flow only returns the token and scopes in the response. The cloudId information is available, but not retrieved or stored. Requiring cloudId on every tool call is redundant and creates more failure points for agents.

Proposed Fix

The preferred approach is to store cloudId at connection time. After the OAuth flow completes, make a post-auth call to GET https://api.atlassian.com/oauth/token/accessible-resources using the access token, and store the returned cloudId alongside the credentials. It's then available to all actions without any per-run resolution.

If connection-time storage isn't feasible, the fallback is to resolve it per run by calling the existing getClouds() method in _makeRequest whenever cloudId isn't provided, and caching it on this._cloudId for the duration of the run.

Either way, cloudId needs to be fully removed from the prop schema — not made optional. An optional prop is still visible in the tool schema and the agent will still try to reason about it.

Error Handling

Scenario Handling
getClouds() returns empty array Throw ConfigurationError: "No Jira Cloud instances found. Please reconnect your Jira account and confirm site access was granted."
getClouds() returns multiple clouds console.log which cloud was selected (first result), continue — do not throw. Wrong-cloud errors surface naturally via Jira API 404/403.
getClouds() call fails Catch and rethrow as ConfigurationError: "Unable to retrieve your Jira Cloud instance. Please check your connection."

Scope of Changes

  • jira.app.mjs: add resolution logic, make _makeRequest async, update the 7 propDefinition options functions that currently receive cloudId from form context (projectID, issueIdOrKey, accountId, transition, commentId, fieldId, contextId)
  • actions/common/issue.mjs and sources/common/common.mjs: remove cloudId prop
  • All 18 actions and 3 sources: remove cloudId prop declaration

References

s0s0physm avatar Mar 05 '26 17:03 s0s0physm

hi, @s0s0physm 😄 I'd really love to work on this.

dataCenter430 avatar Mar 05 '26 19:03 dataCenter430

Hi, @s0s0physm. This issue is not a duplicate of #20221

#20221 added a "Get Cloud ID" action. That's a lookup tool - it returns the cloud ID so you can copy it. #20178 removes cloudId from every Jira action so nobody has to pass it at all.

These are different things.

This problem is still needed

On current project, every Jira action still requires cloudId as a mandatory input. #20221 didn't change that. It just gave users a way to look it up. They still have to pass it into every call.

Before any Jira action, an agent has to call "Get Cloud ID" first, grab the result, then pass it to Create Issue, Assign Issue, Add Comment, etc. Every time. The cloud ID never changes - it's tied to the OAuth connection. There's no reason to ask for it.

What #20178 does

Resolves cloudId automatically inside _makeRequest. One call to the accessible-resources endpoint on the first API request, cached for the rest of the run. The prop is fully removed from all actions and sources - not optional, gone. Agents never see it.

Why it matters

If cloudId is in the schema, agents treat it as something they need to figure out. They'll call Get Cloud ID, try to pass the result around, sometimes get it wrong. Removing it from the schema removes the problem entirely. No extra step, no chaining, no failure mode.


I have already open PR(https://github.com/PipedreamHQ/pipedream/pull/20275) for this. If possible, could you reopen this issue, review my PR? Thanks

Crystora avatar Mar 14 '26 09:03 Crystora

Hi, @s0s0physm would appreciate to review this PR: https://github.com/PipedreamHQ/pipedream/pull/20275

Crystora avatar Mar 16 '26 17:03 Crystora