php-JiraCloud-RESTAPI icon indicating copy to clipboard operation
php-JiraCloud-RESTAPI copied to clipboard

SprintService::getSprintIssues fails to map fields

Open hgriga opened this issue 1 year ago • 3 comments

Hello there!

I wanted to bring to your attention an issue that I've encountered while working with the SprintService and the Jira API version 3. It seems that despite the upgrade, the getSprintIssues method is still fetching data from an older API endpoint, resulting in mismatched response formats and causing type errors in the JSON mapper.

Issue Summary:

After upgrading jira API from version 2 to 3, the getSprintIssues method in the SprintService continues to fetch data from the older API endpoint, which returns some fields in the old string format. However, the JSON mapper expects responses in the new adf format introduced in version 3, resulting in type errors.

Steps to Reproduce:

  1. Upgrade Jira API from version 2 to version 3.
  2. Call the getSprintIssues method from the SprintService.
  3. Observe that the response is fetched from the 1.0 API endpoint, returning some fields string format.
  4. Attempt to parse the response using the JSON mapper, expecting the new adf format.
  5. Encounter type errors due to the mismatch between the expected and actual response formats.

Expected Behavior:

~~The SprintService should be updated to fetch data from the new API endpoint introduced in Jira API version 3, providing responses in the new adf format.~~ The SprintService should be able to handle the fetched data from the older API endpoint. That older API endpoint does not support ADF. The fields are returned as basic strings.

Proposed Solution:

Update the SprintService to fetch data from the new API endpoint introduced in Jira API version 3.

Error

[TypeError] JiraCloud\ADF\AtlassianDocumentFormat::__construct(): Argument #1 ($document) must be of type DH\Adf\Node\Block\Document|DH\Adf\Node\Node, string given, called in /vendor/netresearch/jsonmapper/src/JsonMapper.php on line 708
#0 /vendor/netresearch/jsonmapper/src/JsonMapper.php(706): JiraCloud\ADF\AtlassianDocumentFormat->__construct()
#1 /vendor/netresearch/jsonmapper/src/JsonMapper.php(324): JsonMapper->createInstance()
#2 /vendor/netresearch/jsonmapper/src/JsonMapper.php(327): JsonMapper->map()
#3 /vendor/netresearch/jsonmapper/src/JsonMapper.php(483): JsonMapper->map()
#4 /vendor/complex/jira-cloud-restapi/src/Sprint/SprintService.php(67): JsonMapper->mapArray()

hgriga avatar Apr 03 '24 11:04 hgriga

hi @hgriga, thank you for your contribution. could you change the endpoint, test it, and send it as the PR, please? I'll merge it immediately.

lesstif avatar Apr 22 '24 13:04 lesstif

hi @hgriga, thank you for your contribution. could you change the endpoint, test it, and send it as the PR, please? I'll merge it immediately.

Hello @lesstif. It seems like there is no new API endpoint yet.

I updated the expected behavoir.

hgriga avatar Dec 19 '24 10:12 hgriga

@lesstif The jira rest api is able to handle the sprint requests.

https://github.com/lesstif/php-jira-rest-client/blob/main/src/Sprint/SprintService.php

hgriga avatar Dec 19 '24 10:12 hgriga