zeroclaw-labs/zeroclaw · error

Jira create_ticket failed ({status}): {}

Error message

Jira create_ticket failed ({status}): {}

What it means

Thrown when POST to Jira's issue-creation endpoint returns a non-2xx status. By this point project key, summary, issue type, and parent key all passed local validation, so the failure comes from Jira itself: the response body (truncated) carries Jira's error messages about fields, types, or permissions. Creation errors are almost always 400 with field-level details.

Source

Thrown at crates/zeroclaw-tools/src/jira_tool.rs:912

            .http
            .post(&url)
            .json(&body)
            .timeout(std::time::Duration::from_secs(self.timeout_secs));
        let resp = self.authenticated(req).send().await.map_err(|e| {
            ::zeroclaw_log::record!(
                ERROR,
                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)
                    .with_outcome(::zeroclaw_log::EventOutcome::Failure)
                    .with_attrs(::serde_json::json!({"error": format!("{}", e)})),
                "jira: Jira create_ticket request failed"
            );
            anyhow::Error::msg(format!("Jira create_ticket request failed: {e}"))
        })?;

        let status = resp.status();
        if !status.is_success() {
            let text = resp.text().await.unwrap_or_default();
            anyhow::bail!(
                "Jira create_ticket failed ({status}): {}",
                crate::util_helpers::truncate_with_ellipsis(&text, MAX_ERROR_BODY_CHARS)
            );
        }

        let raw: Value = resp.json().await.map_err(|e| {
            ::zeroclaw_log::record!(
                ERROR,
                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)
                    .with_outcome(::zeroclaw_log::EventOutcome::Failure)
                    .with_attrs(::serde_json::json!({"error": format!("{}", e)})),
                "jira: Failed to parse Jira create_ticket response"
            );
            anyhow::Error::msg(format!("Failed to parse Jira create_ticket response: {e}"))
        })?;

        let key = raw["key"].as_str().unwrap_or("");
        let output = json!({

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Read the Jira error body in the message — it names the exact invalid field or permission.
  2. Confirm the issue_type exists in that specific project (check the project's issue types in Jira UI).
  3. If a parent_key is supplied, ensure the type supports hierarchy (e.g. sub-task under story, story under epic in team-managed/advanced roadmaps).
  4. Fill required custom fields via a direct REST call if the project mandates them, or ask the admin to make them optional.
  5. Verify the token owner has Create Issues permission on the project.

Example fix

// before
jira.create_ticket("PROJ", "Epic", "Migrate storage", None, None, None, Some("PROJ-42")).await?; // Epic cannot have parent -> 400

// after
// epics are top-level; drop the parent, or use a child type
jira.create_ticket("PROJ", "Story", "Migrate storage", None, None, None, Some("PROJ-42")).await?;
Defensive patterns

Strategy: try-catch

Try / catch

match jira.create_ticket("PROJ", it, summary, None, None, None, parent).await {
    Ok(res) => Ok(res),
    Err(e) if e.to_string().contains("(400") => {
        // Jira named the bad field in the body; surface it for field mapping fixes
        Err(e).context("ticket create rejected; check issue type / required fields")
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: issue_type name that does not exist in the project (400 'Could not find valid 'id'' or 'issue type is required'); parent_key given for a non-hierarchy-enabled type or non-Epic parent; a required custom field in the project's create screen; sub-task type without parent; assignee the user cannot assign (403); project key visible but create permission missing (400/403).

Common situations: Scripts assuming every project has Story/Bug when the project only allows Task; Jira Cloud company-managed projects with mandatory custom fields; using an issue type from a different workflow scheme; tokens whose owner lacks 'Create Issues' permission; API version 3 vs 2 differences on description format.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/f93fc5036e3a4fb1. Report an issue: GitHub.