Skip to content

Fix source of truth for custom schemas #764

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

Merged
merged 14 commits into from
Jul 18, 2025
Merged

Conversation

N2D4
Copy link
Contributor

@N2D4 N2D4 commented Jul 14, 2025


Important

Fixes handling of custom schemas by updating connection strings, SQL queries, and removing obsolete triggers and functions.

  • Database Schema Handling:
    • Update connection strings in .github/workflows/e2e-source-of-truth-api-tests.yaml to include ?schema=sot-schema.
    • Add getPrismaSchemaForTenancy and getPrismaSchemaForSourceOfTruth functions in prisma-client.tsx to retrieve schema names.
    • Use sqlQuoteIdent(schema) for schema-specific SQL queries in crud.tsx files.
  • Trigger and Function Removal:
    • Remove triggers project_user_insert_trigger, project_user_update_trigger, project_user_delete_trigger in migration.sql.
    • Remove function update_project_user_count() in migration.sql.
  • Miscellaneous:
    • Add sqlQuoteIdent() function in prisma-client.tsx to safely quote identifiers.

This description was created by Ellipsis for 0923173. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jul 14, 2025

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

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 6:09pm
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 6:09pm
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 6:09pm
stack-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 6:09pm

Copy link
Contributor

@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.

Greptile Summary

This PR modifies the E2E API test workflow configuration to establish a dedicated database schema for source of truth testing. The key changes involve:

  1. Setting up a new database connection string pointing to 'source-of-truth-db' with a specific 'sot-schema'
  2. Updating the environment variables and migration commands to use this new connection

This change improves test isolation and makes the testing environment more maintainable by separating source of truth testing from other test scenarios.

Confidence score: 4.5/5

  1. This PR is very safe to merge as it only affects test infrastructure
  2. The changes are well-isolated, only touching test configuration, and follow good database practice for test isolation
  3. Files needing attention:
    • .github/workflows/e2e-source-of-truth-api-tests.yaml - Verify the connection string format and credentials are correct

1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile

Copy link

recurseml bot commented Jul 14, 2025

✨ No issues found! Your code is sparkling clean! ✨

🗒️ View all ignored comments in this repo
  • The constraint 'TokenStoreType extends string' is too restrictive. It should likely be 'TokenStoreType extends string | object' to match the condition check in line 113 where TokenStoreType is checked against {}
  • Return type mismatch - the interface declares useUsers() returning ServerUser[] but the Team interface that this extends declares useUsers() returning TeamUser[]
  • There is a syntax error in the super constructor call due to the ellipsis operator used incorrectly. Objects aren't being merged correctly. This syntax usage can lead to runtime errors when trying to pass the merged object to 'super()'. Verify that the intended alterations to the object occur before or outside of the super() call if needed.
  • Throwing an error when no active span is found is too aggressive. The log function should gracefully fallback to console.log or another logging mechanism when there's no active span, since not all execution contexts will have an active span. This makes the code less resilient and could break functionality in non-traced environments.

📚 Relevant Docs

  • Function sets backendContext with a new configuration but doesn't pass 'defaultProjectKeys'. Since defaultProjectKeys is required in the type definition and cannot be updated (throws error if tried to set), this will cause a type error.
  • The schema is using array syntax for pick() which is incorrect for Yup schemas. The pick() method in Yup expects individual arguments, not an array. Should be changed to: emailConfigSchema.pick('type', 'host', 'port', 'username', 'sender_name', 'sender_email')

📚 Relevant Docs

  • Creating a refresh token with current timestamp as expiration means it expires immediately. Should set a future date for token expiration.
  • The 'tools' object is initialized as an empty object, even though 'tools' is presumably expected to contain tool definitions. This could cause the server capabilities to lack necessary tool configurations, thus potentially impacting functionalities that depend on certain tool setups.

📚 Relevant Docs

  • 'STACK_SECRET_SERVER_KEY' is potentially being included in every request header without checking its existence again here. Although it's checked during initialization, this could lead to security issues as it's exposed in all communications where the header is logged or captured.

📚 Relevant Docs

  • When adding 'use client' directive at the beginning, it doesn't check if file.text already contains the 'use client' directive. This could lead to duplicate 'use client' directives if the file already has one.

📚 Relevant Docs

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

@N2D4 N2D4 assigned fomalhautb and unassigned N2D4 Jul 17, 2025
@fomalhautb fomalhautb assigned N2D4 and unassigned fomalhautb Jul 18, 2025
@N2D4 N2D4 enabled auto-merge (squash) July 18, 2025 18:01
@N2D4 N2D4 disabled auto-merge July 18, 2025 18:01
@N2D4 N2D4 merged commit 22fe096 into dev Jul 18, 2025
3 of 17 checks passed
@N2D4 N2D4 deleted the source-of-truth-custom-schemas branch July 18, 2025 18:01
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.

2 participants