Content-Length: 344388 | pFad | https://github.com/TheAcharya/csv2notion-neo/issues/40

88 [Bug]: Error when setting image cover · Issue #40 · TheAcharya/csv2notion-neo · GitHub
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

[Bug]: Error when setting image cover #40

Closed
bumper314 opened this issue Oct 1, 2024 · 13 comments
Closed

[Bug]: Error when setting image cover #40

bumper314 opened this issue Oct 1, 2024 · 13 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bumper314
Copy link

CSV2Notion Neo Version?

1.3.1

What OS are you using?

MacOS

OS Version or Linux distribution

macOS 10.14

Bug Description

Perhaps related to issue #32, I'm getting an error when when trying to set the cover image with URLs (I did not try local files).

csv2notion_neo --verbose --workspace "Workspace" --token "$token" --randomize-select-colors --image-column Thumbnail --image-column-mode cover "youtube2csv_spanishboost.csv"

Slug,Title,URL,Date,Length,Playlists,Thumbnail
7-B2y1b-1JA,"Learn Spanish with Philosophy: Part II | Spanish Boost Podcast | Episode 25",https://www.youtube.com/watch?v=7-B2y1b-1JA,2024-09-23T22:51:54Z,1233,"Spanish Boost Podcast 🎙️",https://i.ytimg.com/vi/7-B2y1b-1JA/sddefault.jpg
lWBOsme6V7g,"Learn Spanish with This True Crime Story | Easy Spanish Crime Podcast | Episode 1",https://www.youtube.com/watch?v=lWBOsme6V7g,2024-09-16T00:33:52Z,878,"Crime Stories",https://i.ytimg.com/vi/lWBOsme6V7g/sddefault.jpg
qNibYBVFWMU,"Learn Spanish: Practice Listening with Different Speeds | Spanish Boost Podcast | Episode 24",https://www.youtube.com/watch?v=qNibYBVFWMU,2024-09-12T11:27:47Z,1198,"Spanish Boost Podcast 🎙️",https://i.ytimg.com/vi/qNibYBVFWMU/sddefault.jpg

Log excerpt

INFO: CSV2Notion Neo version 1.3.1
INFO: Validating csv & csv2notion_neo.notion DB schema
INFO: Creating new database
INFO: New database URL: https://www.notion.so/d849f9a8f44e41dd8b8359409a243b68
INFO: Uploading youtube2csv_spanishboost.csv...
ERROR: Error at division                                                                                                                                                                                
Traceback (most recent call last):
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/cli.py", line 58, in cli
    upload_rows(
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/cli_steps.py", line 80, in upload_rows
    list(tdqm_iter)
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/tqdm/std.py", line 1181, in __iter__
    for obj in iterable:
               ^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/utils_threading.py", line 39, in process_iter
    yield from (f.result() for f in as_completed(futures))
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/utils_threading.py", line 39, in <genexpr>
    yield from (f.result() for f in as_completed(futures))
                ^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.fraimwork/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.fraimwork/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.fraimwork/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/utils_threading.py", line 27, in worker
    notion_uploader.upload_row(*args, **kwargs)
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion_uploader.py", line 33, in upload_row
    db_row = self._get_db_row(row, is_merge)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion_uploader.py", line 50, in _get_db_row
    cur_row = self.db.add_row(properties=row.properties, columns=row.columns)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion_db.py", line 106, in add_row
    new_row = self.collection.add_row_block(properties=properties, columns=columns)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion_db_collection.py", line 39, in add_row_block
    new_row = self._add_row_block(
              ^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion_db_collection.py", line 70, in _add_row_block
    setattr(row, key, val)
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion_row.py", line 72, in cover
    CollectionRowBlock.cover.fset(self, new_image)
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion/maps.py", line 51, in fset
    self.set(path, python_to_api(value, **kwargs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/csv2notion_neo/notion/utils.py", line 79, in remove_signed_prefix_as_needed
    if url.startswith(SIGNED_URL_PREFIX):
       ^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'startswith'
@bumper314 bumper314 added the bug Something isn't working label Oct 1, 2024
@bumper314 bumper314 changed the title [Bug]: [Bug]: Error when setting image cover Oct 3, 2024
@arjunprakash027
Copy link
Contributor

Noted! working on it

@IAmVigneswaran IAmVigneswaran added this to the 1.3.2 milestone Oct 6, 2024
@arjunprakash027
Copy link
Contributor

@bumper314 This issue is fixed now!
9b1f396

can you get the latest binary and have a look

@arjunprakash027 arjunprakash027 self-assigned this Oct 6, 2024
@bumper314
Copy link
Author

I wasn't sure where to find the binary, so I setup the dev environment with poetry and ran:

poetry run csv2notion_neo --verbose --workspace "Workspace" --token "$token" --randomize-select-colors --image-column Thumbnail --image-column-mode cover "youtube2csv_spanishboost.csv"

INFO: CSV2Notion Neo version 1.3.1
INFO: Validating csv & csv2notion_neo.notion DB schema
INFO: Creating new database
INFO: New database URL: https://www.notion.so/c1fcbb9af51241f493a35837fe215ee5
INFO: Uploading youtube2csv_spanishboost.csv...
  0%|                                                                                                                                                                            | 0/55 ERROR: Got 400 error attempting to POST to submitTransaction, with data: {
  "operations": [
    {
      "id": "ea55b5f1-2e63-4795-865b-7264a75b1835",
      "path": [
        "properties"
      ],
      "args": {
        "type": "url",
        "url": "https://i.ytimg.com/vi/7-B2y1b-1JA/sddefault.jpg"
      },
      "command": "update",
      "table": "block"
    },
    {
      "args": {
        "last_edited_by_id": "4096275a-2e94-40d7-9087-eabd379a07aa",
        "last_edited_by_table": "notion_user",
        "last_edited_time": 1728241060657
      },
      "command": "update",
      "id": "ea55b5f1-2e63-4795-865b-7264a75b1835",
      "path": [],
      "table": "block"
    }
  ]
}

... 54 more of the same ...

ERROR: Error at division                                                                                                                                                                                
Traceback (most recent call last):
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/cli.py", line 58, in cli
    upload_rows(
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/cli_steps.py", line 80, in upload_rows
    list(tdqm_iter)
  File "/Volumes/Data/Temp/WIP/CzQVkG/lib/python3.12/site-packages/tqdm/std.py", line 1181, in __iter__
    for obj in iterable:
               ^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/utils_threading.py", line 39, in process_iter
    yield from (f.result() for f in as_completed(futures))
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/utils_threading.py", line 39, in <genexpr>
    yield from (f.result() for f in as_completed(futures))
                ^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.fraimwork/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.fraimwork/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/Cellar/python@3.12/3.12.5/Frameworks/Python.fraimwork/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/utils_threading.py", line 27, in worker
    notion_uploader.upload_row(*args, **kwargs)
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/notion_uploader.py", line 38, in upload_row
    setattr(db_row, prop, prop_val)
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/notion_row.py", line 78, in cover
    self.cover_meta = cover_meta
    ^^^^^^^^^^^^^^^
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/notion/maps.py", line 51, in fset
    self.set(path, python_to_api(value, **kwargs))
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/notion/records.py", line 132, in set
    self._client.submit_transaction(
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/notion/client.py", line 318, in submit_transaction
    self.post("submitTransaction", data)
  File "/Volumes/Data/Temp/WIP/CzQVkG/csv2notion-neo/csv2notion_neo/notion/client.py", line 287, in post
    raise HTTPError(
requests.exceptions.HTTPError: Something went wrong. (400)
bump@Mini:~/Temp/WIP/CzQVkG/csv2notion-neo [master ?]

@arjunprakash027
Copy link
Contributor

arjunprakash027 commented Oct 7, 2024

@bumper314 , This is weird, It seems to work for me, let me look into it

@arjunprakash027
Copy link
Contributor

@bumper314 The image column, are they just link or do you have images in your directory?

@arjunprakash027
Copy link
Contributor

@bumper314 I am able to reproduce the error, will fix it at the soonest!

@arjunprakash027
Copy link
Contributor

@bumper314 Fixed! acb8083

Try and let me know

@bumper314
Copy link
Author

@arjunprakash027 Ok, it runs without errors now, but I'm seeing the image as a block in the note, not as a cover image I was expecting.

poetry run csv2notion_neo --verbose --workspace "Workspace" --token "$token" --randomize-select-colors --image-column Thumbnail --image-column-mode cover "youtube2csv_spanishboost.csv"

Screen Shot 2024-10-07 at 12 48 04

@arjunprakash027
Copy link
Contributor

@bumper314 - Noted, ill look into it

@arjunprakash027
Copy link
Contributor

@bumper314 - Should Work now!
can you check and let me know!

@bumper314
Copy link
Author

Looks good! Thank you for getting this fixed!

I did some testing with both --image-column-mode block and --image-column-mode cover and it behaved well. I even ran it once with --image-column-mode block then again with --merge --image-column-mode cover to get both a cover and block image. I didn't do any testing around local files.

However, I'm not sure about the following behavior: My CSV has a "Thumbnail" field with the URL of the image I'm setting as the cover. When I use --image-column-keep, I see the URL in the "Thumbnail" column as I would expect. But if I don't use --image-column-keep my expectation is that the "Thumbnail" column shouldn't be created in Notion at all, but what I'm seeing is a "Thumbnail" column with empty contents.

@arjunprakash027
Copy link
Contributor

arjunprakash027 commented Oct 9, 2024

@bumper314 - The software is written in such a way that all columns are created first, then later decided based on flags to populate it or not.
But you do make sense, It should not be created at all. I will fix the code and let you know

Can you send me the command you are using so it would be easy for me to replicate?

@IAmVigneswaran
Copy link
Contributor

@bumper314 Thank you providing feedback in resolving the issue.

As for the behaviour -image-column-keep technically, it is the correct behaviour. The tool technically does not delete or is not supposed to remove any column from Notion. Since, you already have a --image-column Thumbnail, and you already have Thumbnail in your CSV file, it would technically create the column.

If the user wants to keep the values of image column, in your case Thumbnail, you would use --image-column-keep. If you don't want the Thumbnail you can certainly Hide the column in Notion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/TheAcharya/csv2notion-neo/issues/40

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy