jamalex / jamalex/notion-py

Setting ImageBlock .source seems to result in mangled URL?

Open
#74 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.4k
Forks
470
PR merge metrics
No merged PRs in 30d

Description

I have successfully uploaded images to Notion's AWS S3 backend with `getUploadFileUrl` and gotten back working links. The problem I'm experiencing is when I put them into `notion-py`s `ImageBlock` I'm getting unexpected results (and blank images in the Notion.so client).

Specifically, when setting the `.source` property, the url seems to become mangled. This does not happen with the `.display_source` property. Here's the output of me editing that property manually using valid URLs (probably won't work for you without my cookie token_v2...)

```
>>> im

>>> im.source
'onaws.com/secure.notion-static.com/252cc53c-37d8-4912-ad23-0547230f7a20/..source_postsAnother-4am-Blender-nighteditor1.png'
>>> im.source = 'https://www.notion.so/signed/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F252cc53c-37d8-4912-ad23-0547230f7a20%2F..source_postsAnother-4am-Blender-nighteditor1.png'
>>> im.source
'onaws.com/secure.notion-static.com/252cc53c-37d8-4912-ad23-0547230f7a20/..source_postsAnother-4am-Blender-nighteditor1.png'
>>> im.source = "ajsidosd"
>>> im.source
'ajsidosd'
>>> im.source = 'https://www.notion.so/signed/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F252cc53c-37d8-4912-ad23-0547230f7a20%2F..source_postsAnother-4am-Blender-nighteditor1.png'
>>> im.source
'onaws.com/secure.notion-static.com/252cc53c-37d8-4912-ad23-0547230f7a20/..source_postsAnother-4am-Blender-nighteditor1.png'
>>>
```

This seems to even be a problem when taking an `ImageBlock` uploaded manually to Notion.so through either the web or desktop client, and setting the `.source` property to it's current value (so basically no change), and it will mangle the URL as shown above to this `onaws.com` link.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the ImageBlock source property and compare its behavior with display_source, using getUploadFileUrl to reproduce the reported URL transformation. Verify the behavior with both a valid signed URL and a simple string; done means assigning a valid source URL preserves it rather than producing the truncated onaws.com value.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.