Skip to content

Failing Vercel Preview Protection with context.call#164

Open
tombeckenham wants to merge 7 commits intoupstash:mainfrom
tombeckenham:vercel-preview-test
Open

Failing Vercel Preview Protection with context.call#164
tombeckenham wants to merge 7 commits intoupstash:mainfrom
tombeckenham:vercel-preview-test

Conversation

@tombeckenham
Copy link

DO NOT merge

I have modified email-analyzer-o1 to include the recommended setup for Vercel preview protection. This shows that the first 2 workflow steps work, but the context.call steps fail on vercel preview branches

@tombeckenham
Copy link
Author

See screenshot of the failing workflow on preview branches
image

@CahidArda
Copy link
Collaborator

Hi @tombeckenham,

Thanks for bringing this to our attention.

The simplest fix to get around this issue is to pass:

  • Upstash-Callback-Forward-X (for context.call)
  • Upstash--Failure-Callback-Forward-X (for failure function)
const { POST: handler } = serve<string>(async (context) => {  
  await context.api.openai.call("call", {
    baseURL: "https://testing-ma-feat.requestcatcher.com/",
    body: {
      messages: [],
      model: "gpt-3.5-turbo"
    },
    operation: "chat.completions.create",
    token: "sk-xxxx",
  })
}, {
  qstashClient: new Client({
    token: process.env.QSTASH_TOKEN!,
    baseUrl: process.env.QSTASH_URL!,
    headers: {
      'X-Vercel-Protection-Bypass': 'my-custom-value',
      'upstash-callback-forward-X-Vercel-Protection-Bypass': 'my-custom-value',
      'upstash-failure-callback-forward-X-Vercel-Protection-Bypass': 'my-custom-value'
    }
  })
})

You shouldn't encounter this issue after updating like this.

I will look into whether we can simplify this. If I can't find a way, I will update the docs

@tombeckenham
Copy link
Author

I can confirm the workaround works - provided I included the headers on the triggerWorkflow call as well as the qstashClient. Any chance you could make vercel support simpler? I now have to add 4x headers to the trigger call and the serve function. I'm about to look at using webhooks for another workflow. Is there an equivilent header to add for that?

@tombeckenham
Copy link
Author

context.waitForWebhook seems to fail as well. You can see from the below screenshot that the response is missing the vercel header.

image image

@CahidArda
Copy link
Collaborator

I see. I now understand the issue.

We are planning to change the trigger logic so that the headers passed in trigger with upstash-forward are sent to all requests hitting the endpoint as part of a workflow run. This should fix the issue once and for all.

We are planning to release a fix to resolve this next week.

Let us know if you have any questions!

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