Here’s what the log says: Checking_if_Matching_Task_is_Found step: { ‘$return_value’: { taskFound: false } } AND Checking_if_Matching_Task_is_Found output: { taskFound: undefined }
It looks like the issue is with accessing the taskFound
property from the $return_value
object. You should update the code to access the taskFound
property correctly. Here’s the updated code: export default defineComponent({ async run({ steps }) { const taskFound = steps.Checking_if_Matching_Task_is_Found.$return_value.taskFound; console.log("Checking_if_Matching_Task_is_Found output:", { taskFound: taskFound, }); if (!taskFound) { // No matching task found, proceed to create a new task return { createNewTask: true }; } else { // Matching task found, no need to create a new task return { createNewTask: false }; } }, });
Now, the code should correctly access the taskFound
property from the $return_value
object and work as expected. If you still encounter any issues, please let me know.
I’m also having issues with the next step - create_task_if_needed. Here’s what the logs say: Starting task creation step AND Create new task value: undefined Here’s the code:
import { axios } from “@pipedream/platform”;
export default defineComponent({
async run({ steps }) {
console.log(“Starting task creation step”);
console.log(“Create new task value:”, steps.check_if_task_needs_creation.createNewTask);
**if** (steps.check_if_task_needs_creation.createNewTask) {
**const** url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks";
**const** response = **await** axios(**this**, {
method: "POST",
url: url,
headers: {
Authorization: `Bearer ${**this**.google.$auth.oauth_access_token}`,
"Content-Type": "application/json",
},
data: {
title: steps.Notion_extraction_for_due_dates.title,
notes: steps.Notion_extraction_for_due_dates.privateUrl,
due: steps.Notion_extraction_for_due_dates.$return_value.dueDate,
},
});
console.log("Task creation response:", response);
**return** { newTask: response };
} **else** {
**return** {};
}
},
});
It seems like the issue is with accessing the createNewTask
property from the steps.check_if_task_needs_creation
step. Since we previously fixed the issue with accessing the taskFound
property, let’s update the code to use the correct property: import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ steps }) { console.log("Starting task creation step"); const createNewTask = steps.check_if_task_needs_creation.createNewTask; console.log("Create new task value:", createNewTask); if (createNewTask) { const url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks"; const response = await axios(this, { method: "POST", url: url, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: { title: steps.Notion_extraction_for_due_dates.title, notes: steps.Notion_extraction_for_due_dates.privateUrl, due: steps.Notion_extraction_for_due_dates.$return_value.dueDate, }, }); console.log("Task creation response:", response); return { newTask: response }; } else { return {}; } }, });
Now, the code should correctly access the createNewTask
property and work as expected. If you still encounter any issues, please let me know.
I used this code but still got the same error: Create new task value: undefined
import { axios } from “@pipedream/platform”;
export default defineComponent({
async run({ steps }) {
console.log(“Starting task creation step”);
const createNewTask = steps.check_if_task_needs_creation.createNewTask;
console.log(“Create new task value:”, createNewTask);
**if** (createNewTask) {
**const** url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks";
**const** response = **await** axios(**this**, {
method: "POST",
url: url,
headers: {
Authorization: `Bearer ${**this**.google.$auth.oauth_access_token}`,
"Content-Type": "application/json",
},
data: {
title: steps.Notion_Extraction_for_Due_Dates.$return_value.title,
notes: steps.Notion_Extraction_for_Due_Dates.$return_value.privateUrl,
due: steps.Notion_extraction_for_due_dates.$return_value.dueDate,
},
});
console.log("Task creation response:", response);
**return** { newTask: response };
} **else** {
**return** {};
}
},
});
I apologize for the confusion. It seems like the issue might be with the check_if_task_needs_creation
step not setting the createNewTask
property correctly. Can you please share the code for the check_if_task_needs_creation
step? This will help me identify the issue and provide a solution.
Here’s the code for that: export default defineComponent({
async run({ steps }) {
const taskFound = steps.Checking_if_Matching_Task_is_Found.$return_value.taskFound;
console.log("Checking_if_Matching_Task_is_Found output:", {
taskFound: taskFound,
});
**if** (!taskFound) {
_// No matching task found, proceed to create a new task_
**return** { createNewTask: **true** };
} **else** {
_// Matching task found, no need to create a new task_
**return** { createNewTask: **false** };
}
},
});
Thank you for providing the check_if_task_needs_creation
step code. It seems to be correct. However, the issue might be related to the step names. In the task creation step, you’re using steps.check_if_task_needs_creation.createNewTask
, but in the provided code, the step name is steps.Checking_if_Matching_Task_is_Found
. Please update the task creation step code to use the correct step name: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ async run({ steps }) { console.log(“Starting task creation step”); const createNewTask = steps.Checking_if_Matching_Task_is_Found.createNewTask; console.log(“Create new task value:”, createNewTask); if (createNewTask) { const url = “https://tasks.googleapis.com/tasks/v1/lists/@default/tasks”; const response = await axios(this, { method: “POST”, url: url, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}
, “Content-Type”: “application/json”, }, data: { title: steps.Notion_Extraction_for_Due_Dates.$return_value.title, notes: steps.Notion_Extraction_for_Due_Dates.$return_value.privateUrl, due: steps.Notion_extraction_for_due_dates.$return_value.dueDate, }, }); console.log(“Task creation response:”, response); return { newTask: response }; } else { return {}; } }, });
In the code, could you make the title, notes, and due props for the configuration above?
Sure, I’ve updated the code to include title
, notes
, and due
as props for the configuration: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { title: { type: "string", label: "Task Title", }, notes: { type: "string", label: "Task Notes", }, due: { type: "string", label: "Task Due Date", }, }, async run({ steps }) { console.log("Starting task creation step"); const createNewTask = steps.Checking_if_Matching_Task_is_Found.createNewTask; console.log("Create new task value:", createNewTask); if (createNewTask) { const url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks"; const response = await axios(this, { method: "POST", url: url, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: { title: this.title, notes: this.notes, due: this.due, }, }); console.log("Task creation response:", response); return { newTask: response }; } else { return {}; } }, });
Now, the title
, notes
, and due
values will be taken from the props provided by the user in the Pipedream UI.
I’m using this code and testing it with a new task, but I’m still getting a return value of 0
import { axios } from “@pipedream/platform”;
export default defineComponent({
props: {
title: {
type: “string”,
label: “Task Title”,
},
notes: {
type: “string”,
label: “Task Notes”,
},
due: {
type: “string”,
label: “Task Due Date”,
},
},
async run({ steps }) {
console.log(“Starting task creation step”);
const createNewTask = steps.Checking_if_Matching_Task_is_Found.createNewTask;
console.log(“Create new task value:”, createNewTask);
**if** (createNewTask) {
**const** url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks";
**const** response = **await** axios(**this**, {
method: "POST",
url: url,
headers: {
Authorization: `Bearer ${**this**.google.$auth.oauth_access_token}`,
"Content-Type": "application/json",
},
data: {
title: **this**.title,
notes: **this**.notes,
due: **this**.due,
},
});
console.log("Task creation response:", response);
**return** { newTask: response };
} **else** {
**return** {};
}
},
});
I see that you’re trying to create a new task using the provided code. If you’re getting a return value of 0, it might be because the createNewTask
value is false, which means the code is not entering the task creation block. To better understand the issue, could you please provide more information about the steps.Checking_if_Matching_Task_is_Found.createNewTask
value? What does the step Checking_if_Matching_Task_is_Found
do, and how is the createNewTask
value determined? This information will help me identify the issue and provide a solution.
I’m using this code
import { axios } from “@pipedream/platform”;
export default defineComponent({
props: {
title: {
type: “string”,
label: “Task Title”,
},
notes: {
type: “string”,
label: “Task Notes”,
},
due: {
type: “string”,
label: “Task Due Date”,
},
},
async run({ steps }) {
console.log(“Starting task creation step”);
const createNewTask = steps.check_if_task_needs_creation.$return_value.createNewTask;
console.log(“Create new task value:”, createNewTask);
**if** (createNewTask) {
**const** url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks";
**const** response = **await** axios(**this**, {
method: "POST",
url: url,
headers: {
Authorization: 'Bearer ${this.google.$auth.oauth_access_token}",
"Content-Type": "application/json",
},
data: {
title: **this**.title,
notes: **this**.notes,
due: **this**.due,
},
});
console.log("Task creation response:", response);
**return** { newTask: response };
} **else** {
**return** {};
}
},
});
But I got this code error:
SyntaxError: Unterminated string constant (29:25)
at pp$4.raise (/var/task/node_modules/acorn/dist/acorn.js:2927:15)
at pp$9.readString (/var/task/node_modules/acorn/dist/acorn.js:4891:67)
at pp$9.getTokenFromCode (/var/task/node_modules/acorn/dist/acorn.js:4673:19)
at anonymous.getTokenFromCode (/var/task/node_modules/acorn-node/lib/private-class-elements/index.js:77:48)
at pp$9.readToken (/var/task/node_modules/acorn/dist/acorn.js:4409:17)
at pp$9.nextToken (/var/task/node_modules/acorn/dist/acorn.js:4400:17)
at pp$9.next (/var/task/node_modules/acorn/dist/acorn.js:4357:10)
at pp.eat (/var/task/node_modules/acorn/dist/acorn.js:628:12)
at pp$3.parsePropertyValue (/var/task/node_modules/acorn/dist/acorn.js:2629:14)
at pp$3.parseProperty (/var/task/node_modules/acorn/dist/acorn.js:2621:10)
I see the issue in your code. There’s a missing single quote in the Authorization header, which is causing the syntax error. Here’s the corrected line: ```
Authorization: Bearer ${this.google.$auth.oauth_access_token}
,
I’m now getting this error of 401 invalid authentication credentials:
at null.createError (/tmp/__pdg__/dist/code/1bbf4230cb0a92ee7f37fbe3cd150af186690b5a473adc093895f80b20499552/node_modules/.pnpm/axios@0.21.4/node_modules/axios/lib/core/createError.js:16:15)
at null.settle (/tmp/__pdg__/dist/code/1bbf4230cb0a92ee7f37fbe3cd150af186690b5a473adc093895f80b20499552/node_modules/.pnpm/axios@0.21.4/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/tmp/__pdg__/dist/code/1bbf4230cb0a92ee7f37fbe3cd150af186690b5a473adc093895f80b20499552/node_modules/.pnpm/axios@0.21.4/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (node:events:526:35)
at null.endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
I’m sorry you’re experiencing this issue. The 401 error indicates that the authentication credentials are invalid. Please double-check your Google API credentials and ensure that you have the correct OAuth access token and the necessary API permissions. If you’re still having trouble, please visit https://pipedream.com/support for more support options.
Can you change the code so that the authorization is in a prop too?
Sure, I can modify the code to include the authorization as a prop. Here’s the updated code: import { Octokit } from '@octokit/rest'; export default defineComponent({ name: "Action Demo", description: "This is a demo action", key: "action_demo", version: "0.0.3", type: "action", props: { github: { type: "app", app: "github", }, accessToken: { type: "string", label: "Access Token", description: "Enter your GitHub access token", secret: true, }, }, async run() { const octokit = new Octokit({ auth: this.accessToken, }); return (await octokit.rest.repos.get({ owner: 'pipedreamhq', repo: 'pipedream', })).data; }, });
In this updated code, I’ve added an accessToken
prop to accept the GitHub access token as input. The auth
property in the Octokit
constructor now uses this.accessToken
instead of this.github.$auth.oauth_access_token
.
Can you modify this code to add the google tasks authorization as a prop?
import { axios } from “@pipedream/platform”;
export default defineComponent({
props: {
title: {
type: “string”,
label: “Task Title”,
},
notes: {
type: “string”,
label: “Task Notes”,
},
due: {
type: “string”,
label: “Task Due Date”,
},
},
async run({ steps }) {
console.log(“Starting task creation step”);
const createNewTask = steps.check_if_task_needs_creation.$return_value.createNewTask;
console.log(“Create new task value:”, createNewTask);
**if** (createNewTask) {
**const** url = "https://tasks.googleapis.com/tasks/v1/lists/@default/tasks";
**const** response = **await** axios(**this**, {
method: "POST",
url: url,
headers: {
Authorization: 'Bearer ${this.google.$auth.oauth_access_token}',
"Content-Type": "application/json",
},
data: {
title: **this**.title,
notes: **this**.notes,
due: **this**.due,
},
});
console.log("Task creation response:", response);
**return** { newTask: response };
} **else** {
**return** {};
}
},
});