Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Description

  • fix(kb-perms): search tool perms to use new system
  • fix(nextjs): add force dynamic to 38 routes
  • fix(webhooks): immediate acks only for teams

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

@vercel
Copy link

vercel bot commented Jul 25, 2025

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

Name Status Preview Comments Updated (UTC)
sim (staging) ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 7:43pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 25, 2025 7:43pm

@icecrasher321 icecrasher321 merged commit c91c132 into main Jul 25, 2025
7 checks passed
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 implements three key fixes across the codebase:

  1. Force-dynamic routes fix: Adds export const dynamic = 'force-dynamic' to 38 API routes to prevent Next.js from statically optimizing routes that require server-side execution. This directive ensures routes that depend on user sessions, authentication, and database queries are always rendered dynamically rather than being cached or pre-rendered.

  2. Knowledge base permissions refactor: Updates the knowledge base search system to use a new workspace-based permissions model. The changes replace direct database ownership checks with calls to checkKnowledgeBaseAccess utility function, enabling proper workspace collaboration where users can access knowledge bases through workspace permissions rather than just direct ownership.

  3. Webhook processing optimization: Refactors webhook handling to implement immediate acknowledgment specifically for Microsoft Teams webhooks while maintaining synchronous execution for other providers. Teams webhooks now return immediate responses (status 200) without waiting for workflow execution, addressing timing requirements where Teams expects quick responses to prevent timeouts and duplicate messages.

Additionally, a critical bug fix in workflow execution addresses authentication issues in nested workflows by passing the actual child workflow ID instead of the execution ID to the subExecutor.execute() method, ensuring proper authentication for API calls within child workflows.

These changes collectively address caching issues, improve collaboration features, optimize webhook reliability, and fix authentication problems without breaking existing functionality.

Confidence score: 4/5

• This PR is generally safe to merge with mostly configuration changes and well-tested refactoring
• Score reduced due to one potential logic issue in workspace member removal route that could affect admin validation
• Files needing attention: apps/sim/app/api/workspaces/members/[id]/route.ts for admin check logic, apps/sim/lib/webhooks/utils.ts for webhook processing changes

42 files reviewed, 3 comments

Edit Code Review Bot Settings | Greptile

Comment on lines +7 to 9
export const dynamic = 'force-dynamic'

import { getUserEntityPermissions } from '@/lib/permissions/utils'
Copy link
Contributor

Choose a reason for hiding this comment

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

style: export statement placed between imports - consider moving to top with other imports or after all imports for consistency

Comment on lines +281 to +282
// Generate query embedding in parallel with access checks
const queryEmbedding = await generateSearchEmbedding(validatedData.query)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Moving embedding generation after access checks removes the optimization of parallel execution. Consider moving this back inside the access check loop or running it concurrently with the first access check.

Comment on lines +287 to 292
if (inaccessibleKbIds.length > 0) {
return NextResponse.json(
{ error: `Knowledge bases not found: ${missingKbIds.join(', ')}` },
{ error: `Knowledge bases not found or access denied: ${inaccessibleKbIds.join(', ')}` },
{ status: 404 }
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This check for inaccessible KBs creates a potential information leak - it reveals which specific knowledge base IDs exist but are inaccessible. Consider returning a generic error message instead.

arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
v0.3.11: fix force-dynamic routes, webhooks, kb search perms
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