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

Add parentId parameter in core/front apis #9261

Merged
merged 22 commits into from
Dec 11, 2024
Merged

Add parentId parameter in core/front apis #9261

merged 22 commits into from
Dec 11, 2024

Conversation

tdraier
Copy link
Contributor

@tdraier tdraier commented Dec 10, 2024

Description

Adds parent_id in core and front API , in request when upserting a doc/table/folder and in document/table/folder response.
parent_id is not stored in database but we only ensure the value is equals to parents[1].

Risk

Errors when upserting documents/tables/folders. If parent_id is not passed (which is the case for now), nothing should change. Can be rolledback

Deploy Plan

deploy core
then deploy front

Copy link

github-actions bot commented Dec 10, 2024

Warnings
⚠️

Files in **/api/v1/ have been modified and the PR has the documentation-ack label.
Don't forget to run npm run docs and use the Deploy OpenAPI Docs Github action to update https://docs.dust.tt/reference.

Generated by 🚫 dangerJS against e213f12

@tdraier tdraier added the documentation-ack Used to acknowledge that documentation is up-to-date with this PR label Dec 10, 2024
@tdraier tdraier marked this pull request as ready for review December 10, 2024 17:31
Copy link
Contributor

@spolu spolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the array is called parents I wonder if we should just call it parent vs parent_id ?

Copy link
Contributor

@spolu spolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about it, I really think we want to name it parent given that the other field is named parents

@tdraier
Copy link
Contributor Author

tdraier commented Dec 11, 2024

Thinking more about it, I really think we want to name it parent given that the other field is named parents

I find this more consistent to have parent_id (or parentId) as we do for document_id / folder_id / table_id and we're more clear on the fact we're not passing (or receiving) an object. And as the other fields "parents" is going to be removed at some point I don't think we need to align on that one ?

@spolu
Copy link
Contributor

spolu commented Dec 11, 2024

I find this more consistent to have parent_id (or parentId) as we do for document_id / folder_id / table_id and we're more clear on the fact we're not passing (or receiving) an object. And as the other fields "parents" is going to be removed at some point I don't think we need to align on that one ?

Well Stripe does not use _id when refering to other objects (eg creating a refund for a charge here: https://docs.stripe.com/api/refunds/create)

Really think the _id is cumbersome. It's required when upserting of course but otherwise I think it's just more elegant and more usable to not have _id prefix as long as things are clearly documented as string

@spolu
Copy link
Contributor

spolu commented Dec 11, 2024

Other than upsert flow do we already have any _id parameters?

@spolu
Copy link
Contributor

spolu commented Dec 11, 2024

We do have fileId on content fragment creation :/

@spolu
Copy link
Contributor

spolu commented Dec 11, 2024

Even for table upsert this should be a post to /tabe/{tableId} not a post to /tables :/ this API is a mess

@spolu
Copy link
Contributor

spolu commented Dec 11, 2024

Let's make sure to have a proper upsert path for folders

That way we can standardize on create something and you're given an id: POST .../thing
Upsert POST .../thing/:id
Refering to thing in another request: body { thing: string }

@philipperolet
Copy link
Contributor

IMO parent_id is more suited here:

  • consistent with node_id
  • parents will disappear from api long term, so consistency should go with other fields
  • in general, having thing: refer to a sub-object (with other fields) and thing_id to refer to a string is IMO good; otherwise when you see an arg thing: you'll wonder whether it's a string id, or another object.

I think when I say "thing" I refer to the whole thing, and when I say "thing_id" I refer to its id is the most sensible and the convergence point we should aim at for consitency in the API (and in naming in general)

Are you strong on removing _id @spolu ?

@tdraier
Copy link
Contributor Author

tdraier commented Dec 11, 2024

Even for table upsert this should be a post to /tabe/{tableId} not a post to /tables :/ this API is a mess

💯
In front, only tables uses body for passing id - actually in 2 different endpoint, either /tables but also /tables/csv . We should clearly use /tables/[tId] and handle here both csv/table - i think it's perfectly fine to add a post on /tables/[tId] and deprecate the 2 other endpoints

@spolu
Copy link
Contributor

spolu commented Dec 11, 2024

as per IRL stong feeling from @philipperolet to keep parent_id. Fine to go with it under the argument that we already have fileId

@philipperolet
Copy link
Contributor

as per IRL stong feeling from @philipperolet to keep parent_id. Fine to go with it under the argument that we already have fileId

Thanks; I'd be ok to take renaming parents to parent_ids if that would make this choice more reasonable to you. The API v1 users that actually use this field apart from ourselves are close to 0 IMO.

Copy link
Contributor

@philipperolet philipperolet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a batch of coms 👍

core/bin/core_api.rs Outdated Show resolved Hide resolved
core/bin/core_api.rs Show resolved Hide resolved
core/bin/core_api.rs Show resolved Hide resolved
core/bin/core_api.rs Outdated Show resolved Hide resolved
core/bin/core_api.rs Show resolved Hide resolved
core/src/stores/migrations/20241210_nodes_parent.sql Outdated Show resolved Hide resolved
connectors/src/lib/data_sources.ts Outdated Show resolved Hide resolved
connectors/src/lib/data_sources.ts Outdated Show resolved Hide resolved
connectors/src/lib/data_sources.ts Outdated Show resolved Hide resolved
@@ -686,7 +691,8 @@ impl DataSource {
title.as_deref().unwrap_or(document_id),
mime_type.as_deref().unwrap_or("application/octet-stream"),
&tags,
&parents,
parents.get(1).cloned(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seems off?

@@ -142,6 +142,7 @@ pub struct Document {
pub title: String,
pub mime_type: String,
pub tags: Vec<String>,
pub parent_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why diff this file for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we want to return the parent_id here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seen irl with @philipperolet , to be consistent we want to add parent_id in return too

@@ -6,6 +6,7 @@ pub struct Folder {
folder_id: String,
timestamp: u64,
title: String,
parent_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why diff here for now?

core/src/stores/migrations/20241210_nodes_parent.sql Outdated Show resolved Hide resolved
Copy link
Contributor

@philipperolet philipperolet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for me 👍
Left a few coms, not requiring changes (but check them out :) )

core/bin/core_api.rs Show resolved Hide resolved
core/bin/core_api.rs Show resolved Hide resolved
front/lib/api/data_sources.ts Show resolved Hide resolved
@tdraier tdraier merged commit 5e2bd9c into main Dec 11, 2024
4 checks passed
@tdraier tdraier deleted the thomas/parent-id branch December 11, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-ack Used to acknowledge that documentation is up-to-date with this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants