Missing schema if parent field is not set

For the REST api v2, when I search for issues using the JQL search endpoint POST /rest/api/2/search , I set the fields to ["*all" ], but if the parent field of the jira issue is not set, the parent schema won’t be included in the response

Hello @AlisonHu

What you have described is the expected behaviour.

If an Issue doesn’t have a Parent issue set, there is nothing the REST API can tell you, since the child Issue doesn’t have any information it can provide about the other issue.

What a child Issue doesn’t know about a Parent issue, the REST API doesn’t know either.

For other fields (such as “parent link”, “assignee”, and “priority”), even though they are not set, the REST API still returns the schema.
Here is an example:

{
  "expand": "names,schema",
  "startAt": 0,
  "maxResults": 1,
  "total": 1,
  "issues": [
    {
      "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
      "id": "220834",
      "self": "https://api.atlassian.com/ex/jira/5",
      "key": "012",
      "editmeta": {
        "fields": {
          "parent": {
            "required": false,
            "schema": {
              "type": "issuelink",
              "system": "parent"
            },
            "name": "Parent",
            "key": "parent",
            "hasDefaultValue": false,
            "operations": [
              "set"
            ]
          },
          "customfield_10018": {
            "required": false,
            "schema": {
              "type": "any",
              "custom": "com.atlassian.jpo:jpo-custom-field-parent",
              "customId": 10018
            },
            "name": "Parent Link",
            "key": "customfield_10018",
            "operations": [
              "set"
            ]
          },
          "assignee": {
            "required": false,
            "schema": {
              "type": "user",
              "system": "assignee"
            },
            "name": "Assignee",
            "key": "assignee",
            "autoCompleteUrl": "https://api.atlassian.com",
            "operations": [
              "set"
            ]
          },
          "priority": {
            "required": false,
            "schema": {
              "type": "priority",
              "system": "priority"
            },
            "name": "Priority",
            "key": "priority",
            "operations": [
              "set"
            ],
            "allowedValues": [
            ]
          }
        }
      },
      "fields": {
        "customfield_10018": {
          "hasEpicLinkFieldDependency": false,
          "showField": true
        },
        "assignee": null,
        "priority": {
          "self": "https://api.atlassian.com/ex/jira/50faea7a-8b81-44a1-ba12-5d36cfc498a9/rest/api/2/priority/10006",
          "iconUrl": "https://cdn4.iconfinder.com/data/icons/miu/22/editor_pencil_pen_edit_write_-16.png",
          "name": "Not Set",
          "id": "10006"
        }
      }
    }
  ],
  "names": {
    "customfield_10018": "Parent Link",
    "assignee": "Assignee",
    "priority": "Priority"
  },
  "schema": {
    "customfield_10018": {
      "type": "any",
      "custom": "com.atlassian.jpo:jpo-custom-field-parent",
      "customId": 10018
    },
    "assignee": {
      "type": "user",
      "system": "assignee"
    },
    "priority": {
      "type": "priority",
      "system": "priority"
    }
  }
}

If you mean that the entire schema of the Parent object should be returned, with empty values, when the issue doesn’t have a Parent… but that’s not happening, then I suggest you log a bug with Atlassian.

If you mean that you think it would be nice if the entire schema of the Parent object was returned, with empty values, when the issue doesn’t have a Parent… then I suggest you log a feature request with Atlassian.

Personally, if you need to know what the schema of the Parent object will be when it does have values that can be reported, why not just do a query against an issue that does have a Parent? But hey, that’s just how I would deal with it.

Hi @AlisonHu
the Parent field isn’t a real issue field, that’s why it doesn’t really have a schema like other fields. It’s a synthetic field that, behind the scenes, is implemented differently based on the position of the issue in the issue hierarchy. For historical reasons, the issue/subtask, Epic/Issue, and Initiative/Epic (or any other Portfolio-related) relationships are implemented completely differently in Jira.
You can simply consider that the Parent field is a single-value field that points to another issue, and you’ll have to hardcode that.

Why is there a parent schema in the editmeta? Does it mean that different issues can have different parent schemas?

No, the schema will always be the same when present - it’s a single issue.

In the example above, the parent is not set, but there is a parent schema in the editmeta, why not add the same schema to schema?

Very valid question, but I don’t think Atlassian will care enough to fix that.

2 Likes