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

chore: add support for full log message in persist API #2659

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented Aug 30, 2024

Describe your changes

Following up on #2658 Please review this one first

Adding support for passing full log message to persistAPI. We are still sending legacy simplified logs for now.

Issue ticket number and link

https://linear.app/nango/issue/NAN-1525/improve-actions-error-logs

Checklist before requesting a review (skip if just adding/editing APIs & templates)

  • I added tests, otherwise the reason is:
  • I added observability, otherwise the reason is:
  • I added analytics, otherwise the reason is:

Summary by CodeRabbit

  • New Features

    • Enhanced logging functionality with support for a new log structure, allowing for more detailed log entries.
    • Introduced a new interface for improved request body handling in the logging system.
  • Bug Fixes

    • Updated error messages for deletion and update operations to provide clearer feedback to users.
  • Documentation

    • Improved clarity in error handling responses to better reflect the nature of failures.

Copy link

coderabbitai bot commented Aug 30, 2024

Walkthrough

The changes involve updates to error handling messages in deleteRecords.ts and putRecords.ts, clarifying the nature of operation failures. Additionally, postLog.ts has been significantly modified to enhance logging functionality by introducing a new request body structure that supports both legacy and new log formats, along with updated error handling and type declarations.

Changes

Files Change Summary
packages/persist/lib/routes/environment/.../deleteRecords.ts
packages/persist/lib/routes/environment/.../putRecords.ts
Modified error messages in the handler functions to accurately reflect the nature of operation failures (deletion vs. updating).
packages/persist/lib/routes/environment/.../postLog.ts Enhanced logging functionality by introducing a new LogBody interface, updating the parseBody function, and modifying error handling to ensure consistency.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Logger

    Client->>Server: Send delete request
    Server->>Logger: Log deletion attempt
    Logger-->>Server: Log success/failure
    Server-->>Client: Return response (error message updated)

    Client->>Server: Send update request
    Server->>Logger: Log update attempt
    Logger-->>Server: Log success/failure
    Server-->>Client: Return response (error message updated)

    Client->>Server: Send log request
    Server->>Logger: Log request with new structure
    Logger-->>Server: Log success/failure
    Server-->>Client: Return response
Loading

Poem

🐰 In the meadow where bunnies play,
New logs hop in, brightening the day.
Errors now clear, no more confusion,
With each little change, we dance in elusion.
Hooray for the updates, let’s give a cheer,
For clearer messages, we hold dear! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@TBonnin TBonnin force-pushed the tbonnin/refactor-persist-api branch 4 times, most recently from 736e70f to 524f426 Compare September 4, 2024 14:15
Base automatically changed from tbonnin/refactor-persist-api to master September 4, 2024 14:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6c6de81 and 00fee1c.

Files selected for processing (3)
  • packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/deleteRecords.ts (1 hunks)
  • packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/putRecords.ts (1 hunks)
  • packages/persist/lib/routes/environment/environmentId/postLog.ts (4 hunks)
Additional comments not posted (8)
packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/putRecords.ts (1)

51-51: LGTM!

The change to the error message aligns it with the intended functionality of the putRecords operation.

packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/deleteRecords.ts (1)

51-51: LGTM!

The updated error message accurately reflects the operation being performed and improves clarity in the API's response.

packages/persist/lib/routes/environment/environmentId/postLog.ts (6)

11-16: LGTM!

The code changes are approved.


17-22: LGTM!

The code changes are approved.


24-82: LGTM!

The code changes are approved.


90-90: LGTM!

The code changes are approved.


99-105: LGTM!

The code changes are approved.


118-147: LGTM!

The code changes are approved.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 00fee1c and eb233d5.

Files selected for processing (3)
  • packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/deleteRecords.ts (1 hunks)
  • packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/putRecords.ts (1 hunks)
  • packages/persist/lib/routes/environment/environmentId/postLog.ts (4 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/deleteRecords.ts
  • packages/persist/lib/routes/environment/environmentId/connection/connectionId/sync/syncId/job/jobId/putRecords.ts
Additional comments not posted (6)
packages/persist/lib/routes/environment/environmentId/postLog.ts (6)

11-16: LGTM!

The code changes are approved.


24-27: LGTM!

The code changes are approved.


29-82: LGTM!

The code changes are approved.


90-90: LGTM!

The code changes are approved.


99-105: LGTM!

The code changes are approved.


118-145: LGTM!

The code changes are approved.

@TBonnin TBonnin merged commit f202839 into master Sep 4, 2024
23 checks passed
@TBonnin TBonnin deleted the tbonnin/persist-full-log branch September 4, 2024 16:45
TBonnin added a commit that referenced this pull request Sep 4, 2024
TBonnin added a commit that referenced this pull request Sep 5, 2024
## Describe your changes

Please review #2659 first

Sending full message logs from scripts instead of simplified ones
allowing:
- to attach request and response when proxying 
- better display of `nango.log('with payload', {a: 1})`. Payload now
shows as payload in the UI and it is not appended as string to the
message anymore. It is automatically fixing the display of validation
output for instance

![Screenshot 2024-08-30 at 14 28
51](https://github.com/user-attachments/assets/a9936d0b-3235-45fc-9f90-4881189e8b64)

![Screenshot 2024-08-30 at 14 28
04](https://github.com/user-attachments/assets/6e1cc977-74e0-4958-8f0b-e91f15399abc)

![Screenshot 2024-08-30 at 14 29
19](https://github.com/user-attachments/assets/6fe6abac-88f9-4023-b9d7-5239890ce0bb)


## Issue ticket number and link
https://linear.app/nango/issue/NAN-1525/improve-actions-error-logs

## Checklist before requesting a review (skip if just adding/editing
APIs & templates)
- [ ] I added tests, otherwise the reason is: 
- [ ] I added observability, otherwise the reason is:
- [ ] I added analytics, otherwise the reason is: 


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Enhanced logging capabilities with a new structured log format,
including additional fields for improved detail and clarity.
- **Bug Fixes**
- Updated logging mechanisms to improve type safety and streamline
logging processes.
- **Chores**
- Removed unnecessary dependencies to simplify the project's dependency
management.
- **Documentation**
- Updated test cases to validate new log structures, ensuring
consistency and clarity in logging behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants