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

Create page decoding fails for null link property #31

Closed
andreabusi opened this issue Aug 15, 2022 · 4 comments
Closed

Create page decoding fails for null link property #31

andreabusi opened this issue Aug 15, 2022 · 4 comments
Labels
wip Work in progress

Comments

@andreabusi
Copy link

andreabusi commented Aug 15, 2022

I'm using pageCreate to create a page inside a database with some properties. Create request succeed, but the response parse fails due to a null link property.

This is the error message that I get:

[ERROR] decoding: valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "properties", intValue: nil), _JSONKey(stringValue: "GCal Link", intValue: nil), CodingKeys(stringValue: "url", intValue: nil)], debugDescription: "Expected String value but found null instead.", underlyingError: nil))

On the Notion database, GCal link is a URL property, that is usually empty:

Screenshot 2022-08-15 at 10 53 01

I'm able to reproduce the issue every time, let me know if you need other info!

@andreabusi
Copy link
Author

andreabusi commented Aug 15, 2022

I found a possible fix for the issue, but I don't know if this is the right one.

Inside PageProperty, I changed the way that the URL is decoded:

        case CodingKeys.url.stringValue:
            let value = try container.decodeIfPresent(
                String.self,
                forKey: .url
            )
            self = .url(URL(string: value ?? ""))

@chojnac chojnac added the wip Work in progress label Aug 16, 2022
@chojnac
Copy link
Owner

chojnac commented Aug 16, 2022

Fixed, what a stupid mistake 🤦

@chojnac chojnac closed this as completed Aug 16, 2022
@chojnac
Copy link
Owner

chojnac commented Aug 16, 2022

Also @andreabusi thanks for reporting it 💯

@andreabusi
Copy link
Author

Nice! Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress
Projects
None yet
Development

No branches or pull requests

2 participants