twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
17.33k stars 2.03k forks source link

Import Notes in GUI and Create One Note API cause errors. #7613

Open drew-hansen opened 6 days ago

drew-hansen commented 6 days ago

Bug Description

When trying to upload notes, the upload succeeds but when I go back (or refresh) the page, it throws the error below. image

I also tried the create one note API. However, it does the same thing. It seems that the issue is with the data type being a string. It is almost as if the data type expected is a json object.

Example: This code succeeds, but causes the error above:

import requests

url = "https://api.twenty.com/rest/notes"

querystring = {"depth":"1"}

payload = {
    "position": 0,
    "title": "title goes here",
    "body": "this is a note",
    "createdBy": { "source": "EMAIL" }
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer xxx"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())

Expected behavior

Notes are inserted and can be viewed.

Technical inputs

Did the underlying data type change? When I export a manually created note, it has a bunch of other fields in a json object (related to the rich text stuff I imagine). It would seem that the API did not get updated to reflect this? not sure...

thisisayushverma commented 6 days ago

/assign

oss-gg[bot] commented 6 days ago

@tejasjaiswal07, you are not registered as a member of this repository, so you can't post oss.gg issues. Please register at oss.gg.

oss-gg[bot] commented 6 days ago

@tejasjaiswal07, you are not registered as a member of this repository, so you can't post oss.gg issues. Please register at oss.gg.

FelixMalfait commented 5 days ago

Hey @drew-hansen great feedback, we should improve this

We use a https://www.blocknotejs.org/docs for notes with a json format yes

There is a conversion mechanism but it's lossy so exporting/re-importing something from twenty wouldn't be idempotent

I guess we should: (1) expose 2 different fields in the API when there is a RichText, one in markdown format, one in json format (keep current name for markdown, and add "Markdown" suffix to the new one (2) in the csv import UI if the field is rich text, provide an optional dropdown to let the user indicate the format and then post to the right field based on that

So this isn't an easy issue, it requires a good understanding of our codebase.

https://github.com/TypeCellOS/BlockNote/blob/6b644f6672b41494900d7e817bebdc8a569aa0e4/docs/pages/docs/editor-api/server-processing.mdx

drew-hansen commented 2 days ago

Ok, I think that makes sense. Just so I understand, are you saying that the current API is not capable of creating a note? Rich text is not a requirement for me. Just plain text would suffice. I am trying to migrate from Hubspot and this is a blocker because I don't want to create a bunch of notes by hand :).

FelixMalfait commented 2 days ago

@drew-hansen yes the expected format in the API is a specific format linked to the BlockNote library we use, we need to change that. Fully agree we should fix it by end of year. I wish we could do this sooner but as you can see there are still a lot of other things we need to tackle 😅