xzebra / notion-blog

GNU General Public License v3.0
15 stars 4 forks source link

Exits After "Querying Notion database" with no error message #10

Open ganeshh123 opened 2 years ago

ganeshh123 commented 2 years ago

After compiling a binary and running, it shows the spinner with "Querying Notion database" and then just exits with no error message.

xzebra commented 2 years ago

It just says “Querying Notion database”? Or it says “❌ Querying Notion database: “?

xzebra commented 2 years ago

If it’s the first one, I don’t know how to test that and may need some more context. If it is the second one, the problem may be of the notion-api library.

Anyways, there is a big pr open and things may change a lot so I wouldn’t worry much about current bugs.

ganeshh123 commented 2 years ago

It's the first one, see below: notion-blog-issues-10 Sorry, I guess its not very helpful to debug without any errors. I look forward to what the PR brings, thanks a lot of starting this project, its exactly what I need!

saltbo commented 2 years ago

you can try the pr: https://github.com/saltbo/notion-md-gen/tree/fly

welcome any feedback for me

ganeshh123 commented 2 years ago

Hmm, the install doesn't work for me:

$ brew install notion-md-gen
Running `brew update --preinstall`...
Warning: No available formula with the name "notion-md-gen".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
saltbo commented 2 years ago

it's not ready

ganeshh123 commented 2 years ago

Allright, could you provide some instructions to compile it?

saltbo commented 2 years ago

you can exec 'go install .' in the project

then exec '$GOPATH/bin/notion-md-gen'

xzebra commented 2 years ago

I look forward to what the PR brings, thanks a lot of starting this project, its exactly what I need!

Hi @ganeshh123, I have discarded the idea of integrating the changes of the pull request so I can help you try to find a solution for this problem or you can choose the @saltbo repository which is a more generic generator.

In case you want to keep with this project, I will need some more info about the problem as I don't know how to replicate it. Could you try to run it on another system or architecture with the same configuration? As I see that you are running it from WSL and it is known by having unexpected bugs.

ganeshh123 commented 2 years ago

Thanks for your offer to help, lets try and figure it out. I need a solution for Hugo specifically, so this is more suitable for me.

As per your suggestion, I tried building it for native Windows, but I get this error:

C:\Code\notion-blog>go build -o ./bin/main cmd/main/main.go
# github.com/janeczku/go-spinner
C:\Users\ganesh\go\pkg\mod\github.com\janeczku\go-spinner@v0.0.0-20150530144529-cf8ef1d64394\spinner.go:39:25: cannot use syscall.Stdout (type syscall.Handle) as type int in argument to terminal.IsTerminal

Maybe the Spinner module doesn't work on Windows?

Anyway in the Linux build, this is my config:

{
    "databaseID": "723a5a8dc0e04461b75b58a50e490024",
    "imagesLink": "",
    "imagesFolder": "posts",
    "contentFolder": "posts",
    "propertyTags": "Tags",
}

Some fields are missing as I don't yet have a blog, as I just want to see how the markdowns look, and I don't have a Description, or Status property for the pages. The database is public, so you can examine it yourself here: https://notion.so/723a5a8dc0e04461b75b58a50e490024

Is it mandatory to have the Status and Description properties on the pages? If so, can they be made optional?

My .env file looks like this:

NOTION_SECRET=secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The token here has edit access to the database.

Hope some of this info is useful, if you need anything else please let me know.

saltbo commented 2 years ago

The package github.com/janeczku/go-spinner seems that windows is not supported. I has replace it by github.com/briandowns/spinner

https://github.com/bonaysoft/notion-md-gen/commit/0a6362f3d78fc342ff76f0978cf364416778cf7b#diff-654572202a140b99457b37d9f657f0382e7f0ff32757b06ff3813395c968bd4c

xzebra commented 2 years ago

As per your suggestion, I tried building it for native Windows, but I get this error:

As @saltbo mentioned, go-spinner may not be compatible with Windows. I can try changing to the mentioned package.

and I don't have a Description, or Status property for the pages.

The application is performing a filtered fetch from the database, but if no filter-prop or published-value are specified, it should return a nil, which should return all elements from the database.

q, err := client.Database.Query(context.Background(), notionapi.DatabaseID(config.DatabaseID),
        &notionapi.DatabaseQueryRequest{
            CompoundFilter: filterFromConfig(config), // <- will be nil
            PageSize:       100,
        })

So I'm not quite sure of what is going on here.

ganeshh123 commented 2 years ago

Sorry for the delayed reply. I tried it with another database (https://ganeshh123.notion.site/3967580d3fb64cb4a4f0a9493ece6ed6) with very simple properties but its still having the same issues. I even tried adding the properties from the example config file, but I am still getting the same issue :(

xzebra commented 2 years ago

Just to make sure, did you create an integration and shared those databases to the integration?

To create an integration, use the following link: https://www.notion.so/my-integrations

I have it with the following permissions: image I guess some of them may be omitted but it's the one I use.

On Notion, go to the database page. Then press Share button and make sure you shared the page with the integration you created. image

ganeshh123 commented 2 years ago

Thanks a lot for trying to help, this is my integration, and the secret is in my .env. image And this is the sharing to the integration for the database: image Not sure what else to try :(

I really dont know much about the Go language but would it be possible for you to compile a Windows executable for me to try?