Skip to content

feat: add Jira investigation tools for incident ticket management (#287)#619

Merged
VaibhavUpreti merged 4 commits into
Tracer-Cloud:mainfrom
hamzzaaamalik:issue/287-jira-integration
Apr 16, 2026
Merged

feat: add Jira investigation tools for incident ticket management (#287)#619
VaibhavUpreti merged 4 commits into
Tracer-Cloud:mainfrom
hamzzaaamalik:issue/287-jira-integration

Conversation

@hamzzaaamalik

@hamzzaaamalik hamzzaaamalik commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds Jira integration tools so the investigation agent can search, read, create, and comment on Jira issues during incident response. Fixes #287.

What changed

  • 4 new investigation tools (auto-discovered by the registry, no manual wiring):

    • jira_search_issues — search issues via JQL
    • jira_issue_detail — fetch full details for a specific issue
    • jira_create_issue — file an incident ticket from investigation findings
    • jira_add_comment — post RCA findings as a comment on an existing ticket
  • Client enhancements (app/services/jira/client.py):

    • Added search_issues() method (POST /rest/api/3/search with JQL)
    • Added make_jira_client() factory function
  • Integration catalog (app/integrations/catalog.py):

    • Wired Jira into classify_integrations(), load_env_integrations(), and resolve_effective_integrations()
    • Supports env vars: JIRA_BASE_URL, JIRA_EMAIL, JIRA_API_TOKEN, JIRA_PROJECT_KEY
  • Added "jira" to EvidenceSource type

Pattern followed

All tools follow the existing OpsGenie integration pattern (BaseTool subclass, is_available(), extract_params(), run()).

Tests

  • 36 new tests covering all 4 tools, search_issues(), and make_jira_client() factory
  • All pass: ruff check ✓, mypy ✓ (0 issues in 348 files), pytest ✓ (1995 passed)
  • Zero regressions against existing test suite

Test plan

  • Lint: make lint
  • Type check: make typecheck
  • Unit tests: pytest tests/tools/test_jira_* tests/integrations/test_jira_* -v
  • Full suite: make test-cov

@greptile-apps

greptile-apps Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Jira incident-management integration: 4 new investigation tools (jira_search_issues, jira_issue_detail, jira_create_issue, jira_add_comment), a search_issues() client method, a make_jira_client() factory, and the corresponding catalog/detect-sources wiring. The implementation follows the existing OpsGenie pattern throughout and is covered by 36 new unit tests.

Confidence Score: 5/5

Safe to merge; all findings are P2 style suggestions with no blocking bugs or data-integrity issues.

The implementation correctly uses POST /rest/api/3/issue/search (the previous endpoint concern is already addressed), follows the established OpsGenie pattern, and is backed by 36 tests with full suite passing. Both remaining findings are P2: an unscoped fallback JQL and a missing upfront project_key guard in JiraCreateIssueTool — neither causes data loss or silent failure.

app/services/jira/client.py (fallback JQL) and app/tools/JiraCreateIssueTool/init.py (project_key guard) have minor P2 suggestions worth reviewing before shipping to production.

Important Files Changed

Filename Overview
app/services/jira/client.py Adds search_issues() and make_jira_client() factory; uses correct POST /rest/api/3/issue/search endpoint; fallback JQL "ORDER BY updated DESC" returns all-instance issues when project_key is unconfigured
app/tools/JiraCreateIssueTool/init.py Creates Jira issues from investigation findings; project_key is optional but silently sends empty key to API if not configured (returns HTTP 400 from Jira) unlike other tools that guard-check required params upfront
app/tools/JiraSearchIssuesTool/init.py JQL search tool; correctly propagates project_key through make_jira_client to search_issues default JQL; follows BaseTool pattern cleanly
app/integrations/catalog.py Wires Jira into classify_integrations, load_env_integrations, and resolve_effective_integrations; follows existing OpsGenie pattern correctly
app/nodes/plan_actions/detect_sources.py Adds Jira source detection with connection_verified:True hardcoded, consistent with all other integrations in this file

Sequence Diagram

sequenceDiagram
    participant Agent as Investigation Agent
    participant Tool as Jira Tool (BaseTool)
    participant Factory as make_jira_client()
    participant Client as JiraClient
    participant Jira as Jira REST API v3

    Agent->>Tool: is_available(sources)
    Tool-->>Agent: bool (checks sources["jira"]["connection_verified"])

    Agent->>Tool: extract_params(sources)
    Tool-->>Agent: {base_url, email, api_token, project_key, ...}

    Agent->>Tool: run(base_url, email, api_token, ...)
    Tool->>Factory: make_jira_client(base_url, email, api_token, project_key)
    Factory-->>Tool: JiraClient | None

    alt jira_search_issues
        Tool->>Client: search_issues(jql, max_results)
        Client->>Jira: POST /rest/api/3/issue/search
        Jira-->>Client: {issues, total}
        Client-->>Tool: {success, issues, total}
    else jira_issue_detail
        Tool->>Client: get_issue(issue_key)
        Client->>Jira: GET /rest/api/3/issue/{key}
        Jira-->>Client: {fields...}
        Client-->>Tool: {success, issue_key, summary, ...}
    else jira_create_issue
        Tool->>Client: create_issue(summary, description, ...)
        Client->>Jira: POST /rest/api/3/issue
        Jira-->>Client: {key, id}
        Client-->>Tool: {success, issue_key, url}
    else jira_add_comment
        Tool->>Client: add_comment(issue_key, body)
        Client->>Jira: POST /rest/api/3/issue/{key}/comment
        Jira-->>Client: {id}
        Client-->>Tool: {success, comment_id}
    end

    Tool-->>Agent: {source, available, ...result}
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: app/services/jira/client.py
Line: 151-152

Comment:
**Unscoped fallback JQL queries all issues across the instance**

When neither `jql` nor `project_key` is configured, the fallback `"ORDER BY updated DESC"` returns all accessible Jira issues across every project in the instance. For Jira instances with many projects this may return noisy, irrelevant results for the investigation agent. Consider returning an explicit error or empty result instead of a broad cross-project scan.

```suggestion
        elif not jql:
            return {"success": False, "error": "No JQL query or project_key configured for Jira search."}
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: app/tools/JiraCreateIssueTool/__init__.py
Line: 471-487

Comment:
**Missing upfront `project_key` guard before API call**

`create_issue()` unconditionally sends `"project": {"key": ""}` when `project_key` is empty, which Jira rejects with a 400. The other tools (`JiraAddCommentTool`, `JiraIssueDetailTool`) validate their required runtime inputs before making any API call. Adding an equivalent guard here gives the investigation agent a clearer error instead of a raw Jira 400 response.

```suggestion
        client = make_jira_client(base_url, email, api_token, project_key)
        if client is None:
            return {
                "source": "jira",
                "available": False,
                "error": "Jira integration is not configured.",
                "issue_key": "",
                "url": "",
            }

        if not (project_key or (client.config.project_key if client else "")):
            return {
                "source": "jira",
                "available": False,
                "error": "project_key is required to create an issue. Set JIRA_PROJECT_KEY or pass project_key.",
                "issue_key": "",
                "url": "",
            }

        result = client.create_issue(
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (4): Last reviewed commit: "fix: use stable /rest/api/3/issue/search..." | Re-trigger Greptile

Comment thread app/nodes/plan_actions/detect_sources.py
Comment thread app/nodes/plan_actions/detect_sources.py
@Devesh36

Copy link
Copy Markdown
Collaborator

Hey @hamzzaaamalik could you please resolve this issues , also if you get stuck somewhere feel free to dm the team at discord . Thanks !!

Comment thread app/services/jira/client.py
@hamzzaaamalik

Copy link
Copy Markdown
Collaborator Author

@Devesh36 Please check now

@hamzzaaamalik hamzzaaamalik requested a review from Devesh36 April 16, 2026 14:22

@VaibhavUpreti VaibhavUpreti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

awesome @hamzzaaamalik !

@VaibhavUpreti VaibhavUpreti merged commit 8e11d86 into Tracer-Cloud:main Apr 16, 2026
11 checks passed
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.

Add Jira integration for incident ticket management

3 participants