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

feat(api): POST /comments GET /comments GET /comments/${commentId} #3383

Merged
merged 13 commits into from
Oct 16, 2024

Conversation

marliessophie
Copy link
Member

@marliessophie marliessophie commented Sep 17, 2024

Important

Add API endpoints for creating and retrieving comments with validation and tests.

  • API Endpoints:
    • Add POST /comments to create comments with CreateCommentRequest and CreateCommentResponse.
    • Add GET /comments to retrieve all comments with optional filters for objectType, objectId, authorUserId, page, and limit.
    • Add GET /comments/{commentId} to retrieve a specific comment by ID.
  • Validation:
    • Implement validateCommentReferenceObject in validateCommentReferenceObject.ts to ensure comments reference valid objects.
  • Models:
    • Define Comment and CommentObjectType in commons.yml.
  • Tests:
    • Add tests in comments.servertest.ts to verify comment creation, retrieval, and validation logic.
  • Misc:
    • Update openapi.yml and postman/collection.json to include new comment endpoints.

This description was created by Ellipsis for 9ab2a64. It will automatically update as commits are pushed.

Copy link

vercel bot commented Sep 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
langfuse-cloud ✅ Ready (Inspect) Visit Preview Oct 16, 2024 9:08pm
langfuse-cloud-us 🔄 Building (Inspect) Visit Preview Oct 16, 2024 9:08pm

@marliessophie marliessophie force-pushed the marlies/lfe-1729-add-comments-via-API branch from 2cebbe7 to 2f4b75d Compare September 17, 2024 12:28
@marliessophie marliessophie marked this pull request as ready for review October 16, 2024 18:01
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. feat-api feat-comments labels Oct 16, 2024
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to d518601 in 1 minute and 24 seconds

More details
  • Looked at 1104 lines of code in 11 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. web/src/pages/api/public/comments/[commentId].ts:18
  • Draft comment:
    prisma.comment.findUnique should be prisma.comment.findFirst to support multiple fields in the where clause.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The use of findUnique is appropriate if id and projectId together form a unique constraint. The comment assumes that multiple fields in the where clause necessitate findFirst, which is not necessarily true. Without evidence that id and projectId do not form a unique constraint, the comment seems speculative.
    I might be missing specific knowledge about the database schema, particularly whether id and projectId form a unique constraint. If they do not, the comment could be valid.
    The comment lacks strong evidence and seems speculative without schema details. The default assumption should be that the code is correct unless proven otherwise.
    Delete the comment as it is speculative and lacks strong evidence. The use of findUnique is likely correct if id and projectId form a unique constraint.

Workflow ID: wflow_GVpWvuIHYGj6u4O8


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

This pull request introduces a new API for managing comments in the Langfuse project, including endpoints for creating, retrieving, and validating comments.

  • Added new API endpoints: POST /comments, GET /comments, and GET /comments/{commentId} in multiple files
  • Implemented server-side tests in web/src/__tests__/comments.servertest.ts to ensure functionality of the new endpoints
  • Created validateCommentReferenceObject.ts to validate comment reference objects before creation
  • Updated web/src/server/api/routers/comments.ts with new query methods for fetching comments and comment counts
  • Added Zod schemas for comment-related API endpoints in web/src/features/public-api/types/comments.ts

11 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

web/src/pages/api/public/comments/index.ts Show resolved Hide resolved
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a9390b9 in 39 seconds

More details
  • Looked at 108 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. web/src/__tests__/comments.servertest.ts:39
  • Draft comment:
    The error message format in the test does not match the actual error message format. Update the expected error message to match the actual format returned by the API.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_ql0a4euFb5QGR6Pa


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 6f93ab9 in 20 seconds

More details
  • Looked at 28 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. web/src/features/public-api/types/comments.ts:30
  • Draft comment:
    Ensure CreateCommentData includes authorUserId if it's required for comment creation. This will maintain consistency across the codebase.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_y5jmqv65Qon9feBk


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a5168fa in 20 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. web/src/features/public-api/types/comments.ts:32
  • Draft comment:
    The use of .strict() is redundant when using .extend() in Zod. Consider removing .strict() on line 32.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of .strict() is redundant when using .strictObject() in Zod.

Workflow ID: wflow_GPAwNErObz45CyIV


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This pull request enhances the comment functionality in the Langfuse API by adding new endpoints and improving existing ones, with a focus on user attribution and flexible querying.

  • Added optional authorUserId field to CreateCommentRequest in fern/apis/server/definition/comments.yml
  • Updated CreateCommentData schema in packages/shared/src/features/comments/types.ts to include nullable authorUserId
  • Implemented new tests in web/src/__tests__/comments.servertest.ts for comment creation and retrieval with author information
  • Updated OpenAPI specification and Postman collection to reflect new comment endpoints and schemas

5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This pull request continues to refine the comment functionality in the Langfuse API, focusing on user attribution and API endpoint implementation.

  • Modified CreateCommentData schema in packages/shared/src/features/comments/types.ts to remove authorUserId field
  • Updated PostCommentsV1Body schema in web/src/features/public-api/types/comments.ts to include optional authorUserId
  • Implemented validation for GetCommentsV1Query schema in web/src/features/public-api/types/comments.ts
  • Added APIComment object schema with authorUserId as nullable field

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Oct 16, 2024
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 1d93369 in 26 seconds

More details
  • Looked at 94 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. web/src/__tests__/comments.servertest.ts:231
  • Draft comment:
    Avoid hardcoding error messages in tests as they may change. Consider using regex or partial matching to verify error content.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The test for invalid objectType correctly expects a 400 error, but the error message in the test is hardcoded and may not match future changes in error messages.

Workflow ID: wflow_8D9S9MIOk8CQ7CPm


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This pull request continues to refine the comment functionality in the Langfuse API, focusing on API endpoint implementation and testing.

  • Added comprehensive test cases in web/src/__tests__/comments.servertest.ts for creating and retrieving comments
  • Implemented new API endpoints in fern/apis/server/definition/comments.yml for POST /comments, GET /comments, and GET /comments/{commentId}
  • Updated OpenAPI specification in web/public/generated/api/openapi.yml to include new comment endpoints and schemas
  • Added validation check in CreateCommentRequest to ensure referenced objects exist before creating a comment

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 9ab2a64 in 30 seconds

More details
  • Looked at 22 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_176MGCe4utsr4Bff


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

web/src/pages/api/public/comments/index.ts Show resolved Hide resolved
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This pull request continues to enhance the comment functionality in the Langfuse API, focusing on implementation details and testing.

  • Implemented POST and GET routes for comments in web/src/pages/api/public/comments/index.ts
  • Added pagination support for the GET /comments endpoint
  • Included validation for comment reference objects using validateCommentReferenceObject function
  • Implemented error handling for cases like invalid object references or missing required parameters

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

web/src/pages/api/public/comments/index.ts Show resolved Hide resolved
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This pull request continues to enhance the comment functionality in the Langfuse API, focusing on implementation details, testing, and database changes.

  • Added Comment model and CommentObjectType enum in packages/shared/prisma/schema.prisma
  • Implemented comprehensive tests for comment creation and retrieval in web/src/__tests__/comments.servertest.ts
  • Updated OpenAPI specification in web/public/generated/api/openapi.yml to include new comment endpoints
  • Modified ClickHouse migrations to add event_ts column and adjust table ordering for traces, observations, and scores

20 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: Experimental PR review

PR Summary

(updates since last review)

This pull request introduces new API endpoints for managing comments in the Langfuse project, focusing on creation and retrieval functionality.

  • Implemented POST /comments, GET /comments, and GET /comments/{commentId} endpoints in web/src/pages/api/public/comments/index.ts
  • Added pagination support for GET /comments with optional filters for objectType, objectId, and authorUserId
  • Included validation for comment reference objects using validateCommentReferenceObject function
  • Updated Prisma schema in packages/shared/prisma/schema.prisma to include Comment model and CommentObjectType enum
  • Expanded test coverage in web/src/__tests__/comments.servertest.ts for new comment endpoints and edge cases

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@marliessophie marliessophie merged commit 7babcbd into main Oct 16, 2024
19 checks passed
@marliessophie marliessophie deleted the marlies/lfe-1729-add-comments-via-API branch October 16, 2024 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat-api feat-comments size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant