Skip to content

Commit

Permalink
Merge pull request #6 from upstash/DX-1356-context-call-wf-and-featur…
Browse files Browse the repository at this point in the history
…e-header

Fix Protocol and Feature Headers in context.call
  • Loading branch information
CahidArda authored Oct 25, 2024
2 parents 774d97f + 33508f1 commit e986782
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 26 deletions.
5 changes: 0 additions & 5 deletions src/context/auto-executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe("auto-executor", () => {
{
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down Expand Up @@ -211,7 +210,6 @@ describe("auto-executor", () => {
body: '{"stepId":0,"stepName":"sleep for some time","stepType":"SleepFor","sleepFor":123,"concurrent":2,"targetStep":1}',
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-delay": "123s",
"upstash-forward-upstash-workflow-sdk-version": "1",
Expand All @@ -226,7 +224,6 @@ describe("auto-executor", () => {
body: '{"stepId":0,"stepName":"sleep until next day","stepType":"SleepUntil","sleepUntil":123123,"concurrent":2,"targetStep":2}',
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down Expand Up @@ -279,7 +276,6 @@ describe("auto-executor", () => {
{
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down Expand Up @@ -332,7 +328,6 @@ describe("auto-executor", () => {
{
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down
4 changes: 0 additions & 4 deletions src/context/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ describe("context tests", () => {
body: '{"stepId":1,"stepName":"my-step","stepType":"Run","out":"\\"my-result\\"","concurrent":1}',
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down Expand Up @@ -186,7 +185,6 @@ describe("context tests", () => {
},
timeout: "20s",
timeoutHeaders: {
"Upstash-Feature-Set": ["WF_NoDelete"],
"Content-Type": ["application/json"],
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: ["1"],
"Upstash-Retries": ["3"],
Expand Down Expand Up @@ -236,7 +234,6 @@ describe("context tests", () => {
body: '{"stepId":0,"stepName":"my-wait-step","stepType":"Wait","waitEventId":"my-event-id","timeout":"20s","concurrent":2,"targetStep":1}',
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand All @@ -251,7 +248,6 @@ describe("context tests", () => {
body: '{"stepId":0,"stepName":"my-run-step","stepType":"Run","concurrent":2,"targetStep":2}',
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down
3 changes: 0 additions & 3 deletions src/serve/authorization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ describe("disabled workflow context", () => {
}),
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down Expand Up @@ -260,7 +259,6 @@ describe("disabled workflow context", () => {
}),
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down Expand Up @@ -315,7 +313,6 @@ describe("disabled workflow context", () => {
}),
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
Expand Down
6 changes: 0 additions & 6 deletions src/serve/serve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ describe("serve", () => {
headers: {
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-feature-set": "WF_NoDelete",
"upstash-retries": "3",
"upstash-method": "POST",
"upstash-workflow-runid": workflowRunId,
Expand All @@ -158,7 +157,6 @@ describe("serve", () => {
headers: {
"content-type": "application/json",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-feature-set": "WF_NoDelete",
"upstash-method": "POST",
"upstash-retries": "3",
"upstash-workflow-runid": workflowRunId,
Expand Down Expand Up @@ -331,7 +329,6 @@ describe("serve", () => {
destination: WORKFLOW_ENDPOINT,
headers: {
"content-type": "application/json",
"upstash-feature-set": "WF_NoDelete",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
"upstash-retries": "3",
Expand Down Expand Up @@ -377,7 +374,6 @@ describe("serve", () => {
headers: {
"content-type": "application/json",
"upstash-delay": "1s",
"upstash-feature-set": "WF_NoDelete",
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
"upstash-retries": "3",
Expand Down Expand Up @@ -422,7 +418,6 @@ describe("serve", () => {
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
"upstash-retries": "3",
"upstash-feature-set": "WF_NoDelete",
"upstash-workflow-init": "false",
"upstash-workflow-runid": "wfr-bar",
"upstash-workflow-url": WORKFLOW_ENDPOINT,
Expand Down Expand Up @@ -472,7 +467,6 @@ describe("serve", () => {
"upstash-forward-upstash-workflow-sdk-version": "1",
"upstash-method": "POST",
"upstash-retries": "3",
"upstash-feature-set": "WF_NoDelete",
"upstash-workflow-init": "false",
"upstash-workflow-runid": "wfr-bar",
"upstash-workflow-url": WORKFLOW_ENDPOINT,
Expand Down
6 changes: 0 additions & 6 deletions src/workflow-requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ describe("Workflow Requests", () => {
test("should create headers without step passed", () => {
const { headers, timeoutHeaders } = getHeaders("true", workflowRunId, WORKFLOW_ENDPOINT);
expect(headers).toEqual({
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
[WORKFLOW_INIT_HEADER]: "true",
[WORKFLOW_ID_HEADER]: workflowRunId,
[WORKFLOW_URL_HEADER]: WORKFLOW_ENDPOINT,
Expand All @@ -369,7 +368,6 @@ describe("Workflow Requests", () => {
}
);
expect(headers).toEqual({
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
[WORKFLOW_INIT_HEADER]: "false",
[WORKFLOW_ID_HEADER]: workflowRunId,
[WORKFLOW_URL_HEADER]: WORKFLOW_ENDPOINT,
Expand Down Expand Up @@ -410,7 +408,6 @@ describe("Workflow Requests", () => {
[WORKFLOW_INIT_HEADER]: "false",
[WORKFLOW_ID_HEADER]: workflowRunId,
[WORKFLOW_URL_HEADER]: WORKFLOW_ENDPOINT,
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION,
"Upstash-Retries": "0",
"Upstash-Callback": WORKFLOW_ENDPOINT,
"Upstash-Callback-Forward-Upstash-Workflow-Callback": "true",
Expand Down Expand Up @@ -440,7 +437,6 @@ describe("Workflow Requests", () => {
failureUrl
);
expect(headers).toEqual({
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
[WORKFLOW_INIT_HEADER]: "true",
[WORKFLOW_ID_HEADER]: workflowRunId,
[WORKFLOW_URL_HEADER]: WORKFLOW_ENDPOINT,
Expand All @@ -467,15 +463,13 @@ describe("Workflow Requests", () => {
}
);
expect(headers).toEqual({
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
"Upstash-Workflow-Init": "false",
"Upstash-Workflow-RunId": workflowRunId,
"Upstash-Workflow-Url": WORKFLOW_ENDPOINT,
"Upstash-Forward-Upstash-Workflow-Sdk-Version": "1",
"Upstash-Workflow-CallType": "step",
});
expect(timeoutHeaders).toEqual({
[WORKFLOW_FEATURE_HEADER]: ["WF_NoDelete"],
"Upstash-Workflow-Init": ["false"],
"Upstash-Workflow-RunId": [workflowRunId],
"Upstash-Workflow-Url": [WORKFLOW_ENDPOINT],
Expand Down
7 changes: 5 additions & 2 deletions src/workflow-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,12 @@ export const getHeaders = (
[WORKFLOW_INIT_HEADER]: initHeaderValue,
[WORKFLOW_ID_HEADER]: workflowRunId,
[WORKFLOW_URL_HEADER]: workflowUrl,
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION,
};

if (!step?.callUrl) {
baseHeaders[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`] = WORKFLOW_PROTOCOL_VERSION;
}

if (failureUrl) {
if (!step?.callUrl) {
baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
Expand All @@ -302,6 +304,7 @@ export const getHeaders = (
// for call url, retry is 0
if (step?.callUrl) {
baseHeaders["Upstash-Retries"] = "0";
baseHeaders[WORKFLOW_FEATURE_HEADER] = "WF_NoDelete";

// if some retries is set, use it in callback and failure callback
if (retries) {
Expand Down

0 comments on commit e986782

Please sign in to comment.