chore(release): staging to production - 2026.02.04 - #928
Conversation
…verwrite Add fast path for existing users in JWT auth to skip findOrCreate logic (~8 queries → ~3). Remove organizationId overwrite in findOrCreateUser that caused users to move to wrong orgs with duplicate auth0Ids.
Each step (stripe, workspaces, default chatflows) now runs with its own guard — no-ops when already set up, self-heals when misaligned.
- Use atomic userRepo.update() for profile fields (race condition fix) - Extract shared finalizeUserSetup() to deduplicate fast/slow paths - Validate JWT org_id matches DB org auth0Id before fast path - Handle null org (deleted) by falling through to slow path
Guardrails (safety checks, PII detection) were only running for authenticated requests. The embed endpoint (/api/v1/prediction/) bypassed all safety checks because it has no user object. Root cause: The code checked `if (user?.organizationId)` before applying guardrails - embed requests don't have a user, so guardrails were skipped entirely. Solution: Use workspaceId (from the chatflow) instead of user?.organizationId. Both workspaceId and orgId are always available in executeFlow, regardless of authentication. Changes: - config.ts: getGuardrailsConfig now takes organizationId directly - FiddlerGuardrailsService.ts: createFromContext takes workspaceId for credential lookup (credentials are workspace-scoped) - buildChatflow.ts: Check workspaceId instead of user?.organizationId at all 3 guardrail locations (input validation, agent flow output, regular flow output) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace update()+findOneBy() with save() to eliminate race conditions in fast path and finalizeUserSetup. Add structured security logging for org mismatches. Add 6 unit tests covering fast/slow path behavior.
…-middleware fix(AGENT-670): optimize auth middleware with fast path, remove org overwrite
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…g previous chat When viewing a previous chat from the sidebar (/chat/[chatId]), selecting a different chatflow from the sidekick selector would only close the dialog without actually switching chatflows. This happened because the code conditionally skipped navigation when a chat already existed. The chat page is a Server Component that fetches data based on URL params. Without navigation, the server component doesn't re-fetch, so the chatflow doesn't change. Fix: Always navigate with router.push() when selecting a sidekick, regardless of whether we're viewing an existing chat. This triggers the server component to re-fetch data for the new chatflow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fix(guardrails): apply Fiddler guardrails to embed endpoint
🔍 Pull Request ReviewThis PR merges staging to production with authentication middleware optimizations and guardrails fixes. Overall, the changes demonstrate excellent engineering with comprehensive testing and careful attention to security. ✅ Strengths1. Performance Optimization (Fast Path)The fast path optimization in
2. Security Improvements
3. Race Condition FixesThe atomic update pattern eliminates the previous 4. Excellent Test Coverage
5. Guardrails Fix for Embed EndpointCritical security fix - embed requests now use
|
…selector-switching fix(AGENT-582): fix chat selector not switching chatflows when viewing previous chat
🔍 PR Review: Staging to Production ReleaseOverviewThis release includes 6 commits focused on bug fixes and performance optimizations, primarily around authentication middleware and guardrails. Overall, the changes are production-ready with excellent test coverage and solid architectural improvements. ✅ Strengths1. Excellent Test CoverageThe new auth middleware tests (
2. Smart Performance OptimizationThe auth middleware fast path (
3. Code Quality Improvements
4. Bug Fixes
🔍 Observations & Considerations1. Guardrails API Signature Change (Moderate Impact)Files: The signature change from Consideration: // Before: passed entire user object
const service = await FiddlerGuardrailsService.createFromContext(chatflowid, user)
// After: passes workspace and org IDs
const service = await FiddlerGuardrailsService.createFromContext(chatflowid, workspaceId, orgId)✅ This is correct - credentials are workspace-scoped, not user-scoped 2. Removed Organization ID Override (
|
| File | Change Type | Risk | Notes |
|---|---|---|---|
index.ts (auth middleware) |
Optimization | Low | Fast path + tests ✅ |
findOrCreateUser.ts |
Security fix | Low | Prevents org override ✅ |
FiddlerGuardrailsService.ts |
API change | Low | Workspace-scoped credentials ✅ |
buildChatflow.ts |
API usage | Low | Updated guardrails calls ✅ |
config.ts |
API usage | Low | Updated config lookup ✅ |
useSidekickSelectionHandlers.ts |
Bug fix | Low | Always navigate ✅ |
index.test.ts |
New tests | N/A | 299 lines of coverage ✅ |
Great work on this release! 🎉
🚀 Release: Staging to Production
Release Date: 2026-02-04
Changes in this release
This PR is automatically created/updated when commits are pushed to staging.
Merging this PR will trigger the release workflow to create a new GitHub release.