Skip to content

fix(ud): Add context wrapping to Cedar Functions#2059

Merged
Tobbe merged 1 commit into
mainfrom
fix/ud-function-context-wrapping
Jul 8, 2026
Merged

fix(ud): Add context wrapping to Cedar Functions#2059
Tobbe merged 1 commit into
mainfrom
fix/ud-function-context-wrapping

Conversation

@Tobbe

@Tobbe Tobbe commented Jul 8, 2026

Copy link
Copy Markdown
Member

Add context wrapping to Cedar Functions for UD deploys. Previously only GraphQL got access to Cedar's context. Now also standard Functions (like web hooks) get access to it

@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit 2ebdac0
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6a4df0fa4d63800008c81ab3

@github-actions github-actions Bot added this to the next-release-patch milestone Jul 8, 2026
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Cedar context wrapping to UD standard functions. The main changes are:

  • Builds request context before calling the generated function handler.
  • Dynamically imports Cedar's async context store.
  • Runs standard function handlers inside a per-request async store.

Confidence Score: 4/5

The UD standard function context path needs a fix before merging.

  • The async store is created empty, so global context reads can miss request and auth data.
  • The new runtime import depends on the deploy artifact including @cedarjs/context for generated UD entries.
  • The change is small and localized.

packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts

Security Review

UD standard functions can still lose global request/auth context, so authorization helpers that read @cedarjs/context may see missing user data.

Important Files Changed

Filename Overview
packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts Adds AsyncLocalStorage wrapping to generated UD standard function modules, but the wrapper does not seed the async store with the built request context.

Reviews (1): Last reviewed commit: "fix(ud): Add context wrapping to Cedar F..." | Re-trigger Greptile

Comment thread packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts
Comment thread packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts
@nx-cloud

nx-cloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 2ebdac0

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 2s View ↗
nx run-many -t build ✅ Succeeded 4s View ↗
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 1m 53s View ↗
nx run-many -t test:types ✅ Succeeded 10s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-08 06:52:36 UTC

@Tobbe Tobbe merged commit 8748a7a into main Jul 8, 2026
51 checks passed
@Tobbe Tobbe deleted the fix/ud-function-context-wrapping branch July 8, 2026 12:50
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 5.0.0-canary.2602

Or try it in a new app with yarn dlx create-cedar-app@5.0.0-canary.2602

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.

1 participant