Skip to content

remove metadata endpoint #883

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

Closed

Conversation

sankalp1999
Copy link
Contributor

@sankalp1999 sankalp1999 commented Aug 8, 2025

Fix #879

Summary by CodeRabbit

  • Removed Features

    • The Metadata Endpoint integration has been removed from all settings, tools, and user interface areas.
    • All related functionality for fetching, displaying, and managing external customer metadata is no longer available.
    • Sorting and actions based on external metadata have been discontinued.
  • Documentation

    • The documentation for configuring and using the Metadata Endpoint has been deleted.
  • Bug Fixes

    • Updated tests and settings pages to remove references to the Metadata Endpoint.
  • Chores

    • Cleaned up related backend logic, database tables, and test factories for metadata endpoints.

Copy link

vercel bot commented Aug 8, 2025

@sankalp1999 is attempting to deploy a commit to the Antiwork Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

jacquez-bot bot commented Aug 8, 2025

Thanks for your contribution! Your PR is missing some required information per our guidelines. Please include screenshots of your test suite passing locally and add more detail about what changes were made to fix the issue.

Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

This change set removes all code, database schema, tests, and documentation related to the "metadata endpoint" feature. It deletes the metadata endpoint management UI, backend logic, API routes, associated database tables, related test suites, and documentation. All references and dependencies on the metadata endpoint functionality have been eliminated across the codebase.

Changes

Cohort / File(s) Change Summary
UI Removal
app/(dashboard)/settings/[tab]/page.tsx, app/(dashboard)/settings/tools/metadataEndpointSetting.tsx
Removed the metadata endpoint settings UI and its import/usage. Deleted the entire component.
Type & Schema Cleanup
app/types/global.d.ts, db/schema/mailboxes.ts, db/schema/mailboxesMetadataApi.ts, db/schema/index.ts
Removed the MetadataEndpoint type, deleted the metadata API table schema and relations, and removed related exports/imports.
Database Migration & Journal
db/drizzle/0112_remove-metadata-endpoint.sql, db/drizzle/meta/_journal.json
Added migration to drop the metadata API table and updated migration journal.
Seed Data
db/seeds/seedDatabase.ts
Removed seeding logic for the metadata API table and related imports.
Backend Logic Removal
lib/data/mailbox.ts, lib/data/mailboxMetadataApi.ts, lib/data/retrieval.ts, lib/metadataApiClient.ts
Removed functions, helpers, and modules for managing, fetching, and authenticating metadata endpoints. Simplified mailbox info retrieval.
AI & Tooling Logic
lib/ai/chat.ts, lib/ai/tools.ts, lib/tools/apiTool.ts
Removed all logic for fetching/updating user metadata via metadata endpoints, including HMAC signing and metadata-based tool creation.
Conversation Search
lib/data/conversation/search.ts
Disabled metadata-based conversation sorting by hardcoding the relevant flag to false.
Job Processing
jobs/handleAutoResponse.ts
Removed metadata fetching and customer upsertion logic from auto-response jobs.
API Router
trpc/router/mailbox/index.ts, trpc/router/mailbox/metadataEndpoint.ts
Removed the metadata endpoint router and its registration in the mailbox router.
Documentation
packages/marketing/content/docs/tools/05-metadata-endpoint.mdx
Deleted documentation for the metadata endpoint feature.
Test Suite Cleanup
tests/jobs/handleAutoResponse.test.ts, tests/lib/data/mailbox.test.ts, tests/lib/metadataApiClient.test.ts, tests/lib/tools/apiTool.test.ts, tests/support/factories/mailboxesMetadataApi.ts, tests/trpc/router/mailbox/conversations/index.test.ts
Removed all tests, mocks, and factories related to metadata endpoint functionality. Updated mailbox info tests to remove metadata endpoint expectations.

Sequence Diagram(s)

Not applicable: All changes are removals and do not introduce or modify control flow.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Remove metadata endpoint (#879)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected. All changes are directly related to the removal of the metadata endpoint feature as specified in the linked issue.

Suggested reviewers

  • binary-koan

Poem

The metadata endpoint hops away,
No more secrets, no more play.
Tables dropped and code erased,
Docs and tests are all replaced.
The codebase lighter, swift, and neat—
A rabbit’s work is now complete! 🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf7a668 and 77d086e.

📒 Files selected for processing (27)
  • app/(dashboard)/settings/[tab]/page.tsx (0 hunks)
  • app/(dashboard)/settings/tools/metadataEndpointSetting.tsx (0 hunks)
  • app/types/global.d.ts (0 hunks)
  • db/drizzle/0112_remove-metadata-endpoint.sql (1 hunks)
  • db/drizzle/meta/_journal.json (1 hunks)
  • db/schema/index.ts (0 hunks)
  • db/schema/mailboxes.ts (0 hunks)
  • db/schema/mailboxesMetadataApi.ts (0 hunks)
  • db/seeds/seedDatabase.ts (3 hunks)
  • jobs/handleAutoResponse.ts (0 hunks)
  • lib/ai/chat.ts (2 hunks)
  • lib/ai/tools.ts (1 hunks)
  • lib/data/conversation/search.ts (1 hunks)
  • lib/data/mailbox.ts (2 hunks)
  • lib/data/mailboxMetadataApi.ts (0 hunks)
  • lib/data/retrieval.ts (0 hunks)
  • lib/metadataApiClient.ts (0 hunks)
  • lib/tools/apiTool.ts (2 hunks)
  • packages/marketing/content/docs/tools/05-metadata-endpoint.mdx (0 hunks)
  • tests/jobs/handleAutoResponse.test.ts (0 hunks)
  • tests/lib/data/mailbox.test.ts (0 hunks)
  • tests/lib/metadataApiClient.test.ts (0 hunks)
  • tests/lib/tools/apiTool.test.ts (0 hunks)
  • tests/support/factories/mailboxesMetadataApi.ts (0 hunks)
  • tests/trpc/router/mailbox/conversations/index.test.ts (0 hunks)
  • trpc/router/mailbox/index.ts (0 hunks)
  • trpc/router/mailbox/metadataEndpoint.ts (0 hunks)
💤 Files with no reviewable changes (19)
  • db/schema/index.ts
  • app/types/global.d.ts
  • tests/lib/data/mailbox.test.ts
  • app/(dashboard)/settings/[tab]/page.tsx
  • trpc/router/mailbox/index.ts
  • tests/trpc/router/mailbox/conversations/index.test.ts
  • jobs/handleAutoResponse.ts
  • tests/jobs/handleAutoResponse.test.ts
  • db/schema/mailboxes.ts
  • lib/data/retrieval.ts
  • packages/marketing/content/docs/tools/05-metadata-endpoint.mdx
  • tests/lib/tools/apiTool.test.ts
  • tests/support/factories/mailboxesMetadataApi.ts
  • db/schema/mailboxesMetadataApi.ts
  • tests/lib/metadataApiClient.test.ts
  • trpc/router/mailbox/metadataEndpoint.ts
  • app/(dashboard)/settings/tools/metadataEndpointSetting.tsx
  • lib/data/mailboxMetadataApi.ts
  • lib/metadataApiClient.ts
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-07-05T19:42:25.716Z
Learnt from: Adarsh9977
PR: antiwork/helper#564
File: lib/data/user.ts:58-90
Timestamp: 2025-07-05T19:42:25.716Z
Learning: In this codebase, the banUser function in lib/data/user.ts is intentionally designed as a void function that performs side effects (banning users) without returning values. The team prefers using await calls without storing results for such side-effect functions.

Applied to files:

  • db/seeds/seedDatabase.ts
  • lib/data/mailbox.ts
  • lib/ai/tools.ts
📚 Learning: 2025-07-01T23:48:38.337Z
Learnt from: binary-koan
PR: antiwork/helper#0
File: :0-0
Timestamp: 2025-07-01T23:48:38.337Z
Learning: When reviewing PRs with database migrations (db/drizzle/*.sql files), ensure both _journal.json and *_snapshot.json files are committed. If they're missing, recommend running `pnpm db:generate` and `pnpm db:migrate`.

Applied to files:

  • db/seeds/seedDatabase.ts
  • lib/data/mailbox.ts
  • db/drizzle/meta/_journal.json
📚 Learning: 2025-07-01T06:48:40.674Z
Learnt from: Adarsh9977
PR: antiwork/helper#580
File: lib/data/user.ts:139-139
Timestamp: 2025-07-01T06:48:40.674Z
Learning: In this codebase, permissions for users are stored in the `userProfiles` table in the database, not in mailbox access metadata. When returning user data, permissions should be fetched from the `userProfiles` table rather than from mailbox-related data structures.

Applied to files:

  • lib/data/mailbox.ts
📚 Learning: 2025-07-01T23:48:38.337Z
Learnt from: binary-koan
PR: antiwork/helper#0
File: :0-0
Timestamp: 2025-07-01T23:48:38.337Z
Learning: When reviewing PRs with database migrations (db/drizzle/*.sql files), ensure both _journal.json and the corresponding *_snapshot.json files are committed. Each migration should have a matching snapshot file with the same number (e.g., 0100_database_optimization.sql should have 0100_snapshot.json). If they're missing, recommend running `pnpm db:generate` and `pnpm db:migrate`.

Applied to files:

  • lib/data/mailbox.ts
  • db/drizzle/meta/_journal.json
📚 Learning: 2025-07-06T12:22:37.139Z
Learnt from: Adarsh9977
PR: antiwork/helper#564
File: trpc/router/user.ts:26-26
Timestamp: 2025-07-06T12:22:37.139Z
Learning: In this codebase, defensive programming with double verification is used for critical user access checks. For example, in trpc/router/user.ts, even though the query filters out users with non-null deletedAt, an additional check `|| user.deletedAt` is kept in the if condition for extra safety to ensure deleted users are not processed.

Applied to files:

  • lib/data/mailbox.ts
🔇 Additional comments (16)
db/drizzle/0112_remove-metadata-endpoint.sql (1)

1-1: Approve migration – snapshot file verified

The corresponding snapshot file db/drizzle/meta/0112_snapshot.json is present alongside the migration, so no further action is needed.

lib/data/conversation/search.ts (1)

159-162: LGTM! Correct disabling of metadata-dependent functionality.

The hardcoding of metadataEnabled to false appropriately disables the conditional ordering by platformCustomers.value that was previously dependent on metadata API availability. This change aligns with the removal of the metadata endpoint feature across the codebase.

Note that this will affect search result ordering - the value-based sorting for highest value conversations will no longer be applied automatically.

db/seeds/seedDatabase.ts (3)

20-20: LGTM! Correct removal of metadata API schema import.

The removal of mailboxesMetadataApi from the schema imports aligns with the metadata endpoint feature removal.


84-84: LGTM! Functionally equivalent assertion placement.

Moving the assertion to immediately follow user creation maintains the same validation while improving code readability.


105-108: LGTM! Improved error handling for database seeding.

The selective error suppression for duplicate key errors (PostgreSQL error code "23505") is appropriate for seeding operations where multiple conversations may share the same email address, while still logging other types of errors.

db/drizzle/meta/_journal.json (1)

789-795: Migration 0112 Journal and Snapshot Verified

The snapshot file db/drizzle/meta/0112_snapshot.json is present and correctly corresponds to the 0112_remove-metadata-endpoint entry in _journal.json. No further action needed.

  • Confirmed journal entry in db/drizzle/meta/_journal.json
  • Confirmed 0112_snapshot.json exists in db/drizzle/meta/
lib/tools/apiTool.ts (2)

10-10: LGTM! Correct cleanup of metadata-related imports.

The removal of metadata API imports (getMetadataApiByMailbox and fetchMetadata) aligns with the comprehensive metadata endpoint feature removal.


134-134: LGTM! Simplified metadata prompt handling.

Hardcoding metadataPrompt to an empty string correctly removes the dynamic metadata fetching logic while maintaining the existing prompt structure. This simplifies the code by eliminating the asynchronous metadata operations that were previously performed in generateSuggestedActions.

Note that this change removes metadata context from AI prompt generation, which may affect the quality of suggested actions for conversations.

lib/ai/chat.ts (2)

1-1: LGTM! Import statement correctly updated.

The import statement properly includes the default crypto export alongside the named imports createHash and randomUUID, which is required for the inline HMAC computation below.


588-590: HMAC computation correctly implemented.

The inline HMAC digest computation is functionally equivalent to the removed helper function and maintains the same security properties. The conversion to base64 string for the signature is correct.

lib/data/mailbox.ts (3)

2-2: LGTM! Unused imports correctly removed.

The removal of unused imports and and mailboxesMetadataApi is appropriate after eliminating the metadata endpoint database query.


6-6: LGTM! Schema import simplified.

Correctly removed the mailboxesMetadataApi import from the schema as it's no longer needed.


38-62: LGTM! Function properly simplified.

The getMailboxInfo function correctly transformed from async to sync since it no longer needs to perform database queries for metadata endpoint information. The returned object appropriately excludes the hasMetadataEndpoint and metadataEndpoint properties while maintaining all other mailbox information.

lib/ai/tools.ts (3)

8-8: LGTM! Import statement correctly simplified.

The import correctly removes metadata-related functions while preserving the getPastConversationsPrompt import needed for the knowledge base search functionality.


17-44: LGTM! Human support function properly maintained.

The requestHumanSupport function correctly maintains its core functionality after removing the metadata update call. The function still properly:

  • Updates conversation status and assignment
  • Triggers human support events
  • Returns appropriate response message

57-147: LGTM! Tool building function remains complete.

The buildTools function properly maintains all essential tools (knowledge base, user email setting, human support request, and mailbox tools) while correctly removing metadata-related functionality. The tool building logic is intact and functional.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

@sankalp1999
Copy link
Contributor Author

Some e2e specs are failing however after running e2e on main as well, it seems these are unrelated to changes introduced in this PR

Screenshot 2025-08-08 at 10 44 51 AM

@sankalp1999
Copy link
Contributor Author

all unit tests passing

Screenshot 2025-08-08 at 1 35 13 PM

@binary-koan binary-koan self-assigned this Aug 8, 2025
@binary-koan
Copy link
Collaborator

(Need to build antiwork/gumroad#772 first, will come back to this after)

@slavingia slavingia closed this Aug 19, 2025
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.

Remove metadata endpoint
3 participants