ctreminiom / go-atlassian

✨ Golang Client Library for Atlassian Cloud.
https://docs.go-atlassian.io
MIT License
131 stars 34 forks source link

confluence: add omitempty to BodyScheme #168

Closed SwiftPush closed 1 year ago

SwiftPush commented 1 year ago

I observed that Confluence appears to have recently made a change to their "Create Content" API (POST /wiki/rest/api/content). They used to accept these fields as null, but will now return an exception if you do so.

{
    "statusCode": 400,
    "message": "com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: com.atlassian.confluence.api.model.content.Content[\"body\"]->com.atlassian.confluence.rest.serialization.EnrichedMapDeserializer$NullIgnoringMap[\"view\"])"
}

Example

This is a minimal example showing a request that fails and a request that suceeds. The only difference being including a null field

Including the view field as null

This request fails

image

Omitting the any null fields

This request succeeds

image
ctreminiom commented 1 year ago

Hi @SwiftPush, thank you so much for your contribution,

I just reviewed and you're right, adding the omitempty tag resolves the problem. But, the library version you're referencing is a little bit outdated, the error handling on the HTTP report is already fixed on the latest version.

I would recommend you update the forked repo, resolve the conflicts, and try it again.

Happy holidays!!

1OOsei commented 1 year ago

Thank you both and happy new year ! I'm facing the same issue on my side so happy to get your fix on the latest version 1.4.4. Were you able to identify the change on atlassian side , I was not on my side unfortunately. I don't see any changelog on API around the 19th of Dec, start day when the behavior changed.

1OOsei commented 1 year ago

I'm also wondering when we could have a new release including this fix, as it's currently preventing us creating/updating our confluence pages and I did not found any simple workaround for now ? thanks

ctreminiom commented 1 year ago

@SwiftPush @1OOsei apologies for the delayed response, the latest version fix this error.

Closing this PR.....

Thanks you for supporting this project!!