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

Fix for inline empty Dictionary: Bitbucket Cloud #280

Merged
merged 4 commits into from
Sep 30, 2019

Conversation

khoogheem
Copy link

This fixes the issue where the json payload for the Comment can have inline as an empty dictionary:

            "inline" : {

            },

vs

            "inline" : {
            "to" : null,
            "path" : "client\/XXX\/Info.plist",
            "from" : 132
            },

@khoogheem khoogheem changed the title Fix for inline empty Dictionary Fix for inline empty Dictionary: Bitbucket Cloud Sep 30, 2019
self.deleted = try container.decode(Bool.self, forKey: .deleted)
self.id = try container.decode(Int.self, forKey: .id)
// protect from "inline": {}
self.inline = (try? container.decodeIfPresent(Inline.self, forKey: .inline)) ?? nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just make path optional too, and that prevents from "inline": {} as well, but also from all the combinations that you can have (only path, only from etc).
If, on the other hand, it either have only zero or all the variables, I would then make them all required, and keep this line, what are your thoughts about this?

Copy link
Author

@khoogheem khoogheem Sep 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly from the json I printed out.. to was set to null. so I don't think you can make them all required.

Decoding JSON is like a losing battle if you don't control it ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be ok I guess with having everything in inline be optional

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looks a good option :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.. so we rather just make all of the fields in inline optional vs the init right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Copy link
Member

@f-meloni f-meloni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, just one small comment :)

@f-meloni
Copy link
Member

Remember also to update the changelog with the change, the link to this PR and to your account :)

Copy link
Member

@f-meloni f-meloni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@f-meloni f-meloni merged commit 7985cf9 into danger:master Sep 30, 2019
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

Successfully merging this pull request may close these issues.

2 participants