Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADF description breaks with issues migrated from Jira Server to Jira Cloud #52

Open
mayrn-techdivision opened this issue Mar 31, 2023 · 3 comments

Comments

@mayrn-techdivision
Copy link

mayrn-techdivision commented Mar 31, 2023

We've recently moved from an on premise Jira Server to Jira Cloud and I'm currently updating an internal tool to be compatible. One of the issues I've faced is that issues are not being mapped successfully when loading them:

Fatal error: Uncaught 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 653 and defined in .../vendor/lesstif/jira-cloud-restapi/src/ADF/AtlassianDocumentFormat.php:21
Stack trace:
#0 .../vendor/netresearch/jsonmapper/src/JsonMapper.php(653): JiraCloud\ADF\AtlassianDocumentFormat->__construct('h3. Hintergrund...')
#1 .../vendor/netresearch/jsonmapper/src/JsonMapper.php(292): JsonMapper->createInstance('\\JiraCloud\\ADF\\...', true, 'h3. Hintergrund...')
#2 .../vendor/netresearch/jsonmapper/src/JsonMapper.php(295): JsonMapper->map(Object(stdClass), Object(JiraCloud\Issue\IssueField))
#3 .../vendor/netresearch/jsonmapper/src/JsonMapper.php(449): JsonMapper->map(Object(stdClass), Object(JiraCloud\Issue\Issue))

I can fix this for now by changing the type of \JiraCloud\Issue\IssueField::$description and the signature of \JiraCloud\Issue\IssueField::setDescription to use ?string instead of ?AtlassianDocumentFormat and get it working for now. However I assume that once I process issues that were created in Jira Cloud rather than migrated, this will fail again.

So basically a stable fix would require \JiraCloud\Issue\IssueField::$description to be of type AtlassianDocumentFormat|string|null and somehow get JsonMapper to support intersection types, trying each of them and picking the one that's mapped successfully.

@lesstif
Copy link
Owner

lesstif commented Apr 16, 2023

Hi @mayrn-techdivision Sorry for the late reply.
Unfortunately, Jason mapper does not support the multiple instance types during serialize/deserialize.
So I suppose that I need to separate the setter function as two, for example.

// for mapper when fetching from the Jira Cloud
public function setDescription(?string $description): static
{

}
// setter
public function setDescriptionByADF(?AtlassianDocumentFormat $description): static
{
}

Could you check this idea, please?

@aaronflorey
Copy link

I'm having the same issue, my issues have a string description. Is there any fix on the horizon?

@lesstif
Copy link
Owner

lesstif commented Nov 21, 2023

Hi @aaronflorey Could you share more information about this? for instance, when do you meet this error? which library version do you use?
and could you share your code with me, please? because I can't recreate the above error on my side.

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

No branches or pull requests

3 participants