lesstif / php-jira-rest-client

PHP classes interact Jira with the REST API.
Other
510 stars 263 forks source link

JSON property "parent" in class "JiraRestApi\Issue\IssueField" must not be NULL #515

Closed Ken-vdE closed 1 year ago

Ken-vdE commented 1 year ago

We're experiencing this error since today: JSON property "parent" in class "JiraRestApi\Issue\IssueField" must not be NULL. Our code has worked stably for weeks. I think Jira cloud is returning different data since this weekend.

I'm simply calling get('SOMEKEY-123') on an IssueService instance.

Here's the trace: /vendor/netresearch/jsonmapper/src/JsonMapper.php in JsonMapper::map at line 216

                $this->setProperty($object, $accessor, null);
                continue;
            }
            $type = $this->removeNullable($type);
        } else if ($jvalue === null) {
            throw new JsonMapper_Exception(
                'JSON property "' . $key . '" in class "'
                . $strClassName . '" must not be NULL'
            );
        }

/vendor/netresearch/jsonmapper/src/JsonMapper.php in JsonMapper::map at line 300

                );
            }
            $child = $this->createInstance($type, true, $jvalue);
        } else {
            $child = $this->createInstance($type, false, $jvalue);
            $this->map($jvalue, $child);
        }
        $this->setProperty($object, $accessor, $child);
    }
    if ($this->bExceptionOnMissingData) {

/vendor/lesstif/php-jira-rest-client/src/Issue/IssueService.php in JiraRestApi\Issue\IssueService::get at line 51

    $ret = $this->exec($this->uri.'/'.$issueIdOrKey.$this->toHttpQueryParameter($paramArray), null);
    $this->log->info("Result=\n".$ret);
    return $issue = $this->json_mapper->map(
        json_decode($ret),
        $issueObject
    );
}
/**
reindeer77 commented 1 year ago

We are having the same issue since today.

you-loan commented 1 year ago

Same issue starting from today

bastian-schur commented 1 year ago

Same issue here.

tomdrissen commented 1 year ago

Same. Looks like the Jira API is adding nullable properties to the response, which wasn't the case before.

ydelwiche commented 1 year ago

Had the same issue. I've modified the JiraCloud\Issue\IssueField class to allow null in the parent setter:

    public function setParent(?Issue $parent): void
    {
        $this->parent = $parent;
    }

This unblocked me until an official fix is available.

RHaytree commented 1 year ago

I also modified the setParent method as shown below:


    /**
     * Set parent
     *
     * @param  Issue|null $parent
     * @return void
     */
    public function setParent(?Issue $parent)
    {
        if (!is_null($parent)) {
            $this->parent = $parent;
        }
    }
Ken-vdE commented 1 year ago

Issue fixed in version 5.5.1