jmuchovej / paperpile-notion

CLI & GitHub Workflow based one-way sync from Paperpile to Notion
MIT License
24 stars 4 forks source link

Error: You don't have an Authors database. Exiting. #38

Open olgabot opened 2 years ago

olgabot commented 2 years ago

Hello, Hope you are doing well! I am having trouble getting the databases configuration right, and I'm not sure what I'm doing wrong.

Any paperpile-notion command causes the error, You don't have an Authors database:

(paperpile-notion)
 ✘  Mon 17 Oct - 10:58  ~/code/sync-paperpile-to-notion   origin ☊ main 1● 
  paperpile-notion authors:clean references.bib -c .config/paperpile-notion/config.js
Found 4960 entries
 ›   Error: You don't have an Authors database. Exiting.

Here is my config:

const databases = {
  articles: {
    // https://www.notion.so/bf32a3bfe5474dc7895a6bf4dacf1a11?v=9211afe0709d4a0682d16accbf9b41dd
    databaseID: "bf32a3bfe5474dc7895a6bf4dacf1a11",
    authorRef: "Authors",
  },
  authors: {
    // https://www.notion.so/e099196d94ab4ff1913a597fff33e8a2?v=639a9240bc194996883b516691538852
    databaseID: "e099196d94ab4ff1913a597fff33e8a2",
    articleRef: "Articles",
  },
}
Here is the Authors database in Notion: ![image](https://user-images.githubusercontent.com/806256/196249758-b71d35ae-88d1-40e2-bfca-0cf6446c3154.png)
And here is the Articles database in Notion: ![image](https://user-images.githubusercontent.com/806256/196249869-c49759f5-d095-465b-809a-d9a7de36decb.png)
Both have the Paperpile jmuchovej/paperpile-notion connection/integration: ![image](https://user-images.githubusercontent.com/806256/196250376-dfb81c0e-aa15-4259-af71-df6719cb04fb.png)

Looking at setupDBs here: https://github.com/jmuchovej/paperpile-notion/blob/b7338b68b18f7fc4e6503665f689b03fa157380e/src/config.ts#L122

What I see is that some assumptions are made about the "Authors" and "Articles" databases. For example, it seems that name is the primary key for Authors, while mine uses title case Name. Changing to name in the Authors database creates the same error. I'm not able to understand what is invalid about my Authors database.

Is there a way to run only the config script to understand how the tool is interpreting the configuration, and validating it? And/or could you provide empty Notion templates of example Authors and Articles databases to get started?

Thank you! Warmest, Olga

EDIT: even if I make the databases publicly viewable, the same "You don't have an Authors database" error occurs

olgabot commented 2 years ago

(EDIT: hit enter too soon)

Update:

The articles:sync command seems to somewhat work, but gives the validation error Authors is expected to be relation.

First, I see an error that both the field "Title" doesn't exist and Authors is expected to be relation:

`paperpile-notion articles:sync references.bib -c .config/paperpile-notion/config.js` ``` (paperpile-notion) ✘  Mon 17 Oct - 11:22  ~/code/sync-paperpile-to-notion   origin ☊ main 1●   paperpile-notion articles:sync references.bib -c .config/paperpile-notion/config.js Found 4960 entries Cumulative time: ~0.00012299623390038807min. Cumulative time: ~0.00023927018344402313min. Cumulative time: ~0.00030029020011425014min. Cumulative time: ~0.00032403093377749126min. Cumulative time: ~0.00035563130080699923min. Cumulative time: ~0.0004037440339724223min. Cumulative time: ~0.00043184866706530255min. Cumulative time: ~0.0004540153334538142min. Cumulative time: ~0.0004831853667894999min. Cumulative time: ~0.0005058494836091995min. Cumulative time: ~0.0005347891499598821min. Cumulative time: ~0.0005698294003804524min. Cumulative time: ~0.0006170606007178624min. Cumulative time: ~0.0006412856499354044min. Cumulative time: ~0.0006530609170595804min. Cumulative time: ~0.0006635629336039225min. Cumulative time: ~0.000680896183848381min. Cumulative time: ~0.0007482262839873631min. Cumulative time: ~0.0007652120331923167min. Cumulative time: ~0.0007769120832284292min. Cumulative time: ~0.0007911792665719986min. Cumulative time: ~0.0008039186000823974min. Cumulative time: ~0.0008197764674822489min. Cumulative time: ~0.0008477775673071542min. Cumulative time: ~0.00086114675005277min. Cumulative time: ~0.0008706465671459834min. Cumulative time: ~0.0008860413173834483min. Cumulative time: ~0.0009025717834631602min. Cumulative time: ~0.0009165610502163569min. Cumulative time: ~0.0009307912498712539min. Cumulative time: ~0.000942212517062823min. Cumulative time: ~0.0009515498667955399min. Cumulative time: ~0.0009657072335481644min. Cumulative time: ~0.0009784391502539317min. Cumulative time: ~0.0009892023166020712min. Cumulative time: ~0.0010229986836512884min. Cumulative time: ~0.001033486583828926min. Cumulative time: ~0.0010433494667212169min. Cumulative time: ~0.001053200967113177min. Cumulative time: ~0.001059900850057602min. Cumulative time: ~0.0010684500167767207min. Cumulative time: ~0.0010756026834249496min. Cumulative time: ~0.0010832450340191523min. Cumulative time: ~0.001092401283979416min. Cumulative time: ~0.0011029464334249496min. Cumulative time: ~0.0011389810840288796min. Cumulative time: ~0.001146881550550461min. Cumulative time: ~0.0011560731172561645min. Cumulative time: ~0.0011642053832610448min. Cumulative time: ~0.0011738417665163674min. Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Title is not a property that exists. Authors is expected to be relation."} ```
After changing Title field of `Articles` from `Name` to `Title`, the database starts filling and I see only the error `Authors is expected to be relation` ![image](https://user-images.githubusercontent.com/806256/196256827-36d13cc5-eb45-4c02-9bdc-7d1af9036994.png) ``` {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: {"object":"error","status":400,"code":"validation_error","message":"Authors is expected to be relation."} Validation Failed: ```

But the Authors property is a relation! So I am very confused.

I stopped that process with Ctrl-C to try authors:sync and got the same error message of: Error: You don't have an Authors database. Exiting.

(paperpile-notion)
 ✘  Mon 17 Oct - 11:27  ~/code/sync-paperpile-to-notion   origin ☊ main 1● 
  paperpile-notion authors:sync references.bib -c .config/paperpile-notion/config.js
Found 4960 entries
 ›   Error: You don't have an Authors database. Exiting.

And then I try to clean the articles database and I think it's assuming the Authors relation is multi_select instead of relation! So how is it both? I'm very confused...

(paperpile-notion)
 ✘  Mon 17 Oct - 11:32  ~/code/sync-paperpile-to-notion   origin ☊ main ↓1 1● 
  paperpile-notion articles:sync references.bib -c .config/paperpile-notion/config.js
Found 4960 entries
^C
(paperpile-notion)                                                                                                                       $(aws_prompt_info)
(paperpile-notion) paperpile-notion articles:clean references.bib -c .config/paperpile-notion/config.js                                  $(aws_prompt_info)
Found 4960 entries
Removing Articles with no Authors.
    APIResponseError: The property type in the database does not match the property type of the filter provided: database property relation does not match
     filter multi_select
    Code: validation_error
olgabot commented 2 years ago

Hello, Hope you're doing well. I got some help from a typescript-y friend on how to install the code locally. For those interested, I did:

Install Yarn

(paperpile-notion)
 ♥ 97%  Mon 17 Oct - 20:13  ~/code/jmuchovej--paperpile-notion   origin ☊ main 3● 
  npm i -g yarn

added 1 package, and audited 2 packages in 2s

found 0 vulnerabilities

Use yarn to install the package

(paperpile-notion)
 ♥ 97%  Mon 17 Oct - 20:13  ~/code/jmuchovej--paperpile-notion   origin ☊ main 3● 
  yarn install
zsh: correct 'yarn' to 'tar' [nyae]? n
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
error https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz: Integrity check failed for "whatwg-url" (computed integrity doesn't match our records, got "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== sha1-lmRU6HZUYuN2RNNib2dCzotwll0=")
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Then if you edit the code, you will need to recompile with yarn build

(paperpile-notion)
 Tue 18 Oct - 20:23  ~/code/jmuchovej--paperpile-notion   origin ☊ main 4● 
  yarn build
yarn run v1.22.19
$ shx rm -rf dist && tsc -b
✨  Done in 5.01s.

I'm really confused why the Authors database isn't working

Here's the code in config.ts with a lot more print statements. What I'm really confused is that the type of authors and articles is both object and yet _.isString only seems to be true for Articles for me?

  console.log("Authors:")
  console.log(authors)
  console.log(typeof authors)
  console.log("Articles:")
  console.log(articles)

  if (_.isString(authors)) {
    console.log("Authors is string")
    let dbID: string = isValidPageID(authors) ?? await getDBbyName(notion, authors)
    databases.authors = <AuthorsDB>{
      databaseID: <string>dbID,
      articleRef: "Articles",
      primaryKey: "name",
    }
  }

  if (_.isString(articles)) {
    let dbID: string = isValidPageID(articles) ?? await getDBbyName(notion, articles)
    databases.articles = <ArticlesDB>{
      databaseID: <string>dbID,
      authorRef: "Authors",
      primaryKey: "ID",
    }
  }

  console.log("_.isString(databases.articles)")
  console.log(_.isString(databases.articles))
  console.log("_.isString(databases.authors)")
  console.log(_.isString(databases.authors))

This is the output I get:

(paperpile-notion)
 ✘  ♥ 83%  Mon 17 Oct - 20:30  ~/code/sync-paperpile-to-notion   origin ☊ main ↓8 3☀ 1● 
  ~/code/jmuchovej--paperpile-notion/bin/run authors:sync references.bib -c .config/paperpile-notion/config.js
Authors:
{
  databaseID: 'e099196d94ab4ff1913a597fff33e8a2',
  articleRef: 'Articles'
}
object
Articles:
{
  databaseID: 'bf32a3bfe5474dc7895a6bf4dacf1a11',
  authorRef: 'Authors'
}
_.isString(databases.articles)
false
_.isString(databases.authors)
false
Found 4960 entries
 ›   Error: You don't have an Authors database. Exiting.

What is even MORE confusing now is that now somehow after adding console.log(typeof articles), authors:sync is working?

(paperpile-notion)
 ✘  Tue 18 Oct - 20:23  ~/code/sync-paperpile-to-notion   origin ☊ main ↓8 3☀ 1● 
  ~/code/jmuchovej--paperpile-notion/bin/run authors:sync references.bib -c .config/paperpile-notion/config.js
Authors:
{
  databaseID: 'e099196d94ab4ff1913a597fff33e8a2',
  articleRef: 'Articles'
}
object
Articles:
{
  databaseID: 'bf32a3bfe5474dc7895a6bf4dacf1a11',
  authorRef: 'Authors'
}
object
_.isString(databases.articles)
false
_.isString(databases.authors)
false
Found 4960 entries

But I'm not seeing my test string of "Authors is string" getting printed.

Let me know if you have any updates! Thank you so much. Warmest, Olga