I apologize for the confusion earlier. It seems that the issue still persists. To further investigate the problem, please share the code for the step that calls the Checking_if_Matching_Task_is_Found
component and any other relevant steps in your workflow. This will help me understand the context and provide a solution to fix the issue.
Here’s that code for that component:
import { URL } from “url”;
export default defineComponent({
props: {
privateUrl: {
type: “string”,
label: “Notion Private URL”,
},
},
async run({ steps }) {
const notionPrivateUrl = new URL(this.privateUrl);
const tasks = steps.list_tasks.$return_value;
console.log("Notion Private URL:", notionPrivateUrl);
console.log("Tasks:", tasks);
**const** matchingTask = tasks.find((task) => {
**if** (task.notes) {
**try** {
**const** taskUrl = **new** URL(task.notes);
**return** taskUrl.pathname === notionPrivateUrl.pathname;
} **catch** (error) {
console.error("Error parsing URL:", error);
}
}
**return** **false**;
});
**if** (matchingTask) {
console.log("Matching Task:", matchingTask);
**return** { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: **true** };
} **else** {
console.log("No matching task found");
**return** { taskFound: **false** };
}
},
});
I apologize for the confusion earlier. I reviewed the code you provided again, and it seems correct. To further investigate the issue, please share the code for the step that calls the Checking_if_Matching_Task_is_Found
component and any other relevant steps in your workflow. This will help me understand the context and provide a solution to fix the issue.
- Checking_if_Matching_Task_is_Found
import { URL } from "url";
export default defineComponent({
props: {
privateUrl: {
type: "string",
label: "Notion Private URL",
},
},
async run({ steps }) {
const notionPrivateUrl = new URL(this.privateUrl);
const tasks = steps.list_tasks.$return_value;
console.log("Notion Private URL:", notionPrivateUrl);
console.log("Tasks:", tasks);
const matchingTask = tasks.find((task) => {
if (task.notes) {
try {
const taskUrl = new URL(task.notes);
return taskUrl.pathname === notionPrivateUrl.pathname;
} catch (error) {
console.error("Error parsing URL:", error);
}
}
return false;
});
if (matchingTask) {
console.log("Matching Task:", matchingTask);
return { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: true };
} else {
console.log("No matching task found");
return { taskFound: false };
}
},
});
- check_if_task_needs_creation
export default defineComponent({
async run({ steps }) {
const taskFound = steps.Checking_if_Matching_Task_is_Found.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 };
}
},
});
- create_task_if_needed
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 {};
}
},
});
- Checking_if_Matching_Task_is_Found
import { URL } from "url";
export default defineComponent({
props: {
privateUrl: {
type: "string",
label: "Notion Private URL",
},
},
async run({ steps }) {
const notionPrivateUrl = new URL(this.privateUrl);
const tasks = steps.list_tasks.$return_value;
console.log("Notion Private URL:", notionPrivateUrl);
console.log("Tasks:", tasks);
const matchingTask = tasks.find((task) => {
if (task.notes) {
try {
const taskUrl = new URL(task.notes);
return taskUrl.pathname === notionPrivateUrl.pathname;
} catch (error) {
console.error("Error parsing URL:", error);
}
}
return false;
});
if (matchingTask) {
console.log("Matching Task:", matchingTask);
return { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: true };
} else {
console.log("No matching task found");
return { taskFound: false };
}
},
});
- check_if_task_needs_creation
export default defineComponent({
async run({ steps }) {
const taskFound = steps.Checking_if_Matching_Task_is_Found.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 };
}
},
});
- create_task_if_needed
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 looks like you have three code steps: 1. Checking_if_Matching_Task_is_Found
: This step checks if there’s a matching task based on the Notion private URL. If a matching task is found, it returns the task ID, task title, and a taskFound
flag set to true. If no matching task is found, it returns a taskFound
flag set to false. 2. check_if_task_needs_creation
: This step checks the taskFound
flag from the previous step. If taskFound
is false, it means no matching task was found, and it returns a createNewTask
flag set to true. If taskFound
is true, it means a matching task was found, and it returns a createNewTask
flag set to false. 3. create_task_if_needed
: This step checks the createNewTask
flag from the previous step. If createNewTask
is true, it creates a new task using the Google Tasks API with the title, notes, and due date extracted from the Notion page. If createNewTask
is false, it doesn’t create a new task and returns an empty object. Please let me know if you have any questions or need further clarification on any part of the code.
Yes, my question is why it’s not working?
I apologize for the inconvenience. To help you better, I need more information about the issue you’re facing. Are you encountering any error messages or having trouble with a specific part of the code? Please provide more details so I can assist you effectively.
The following code is giving me lots of issues in the logs:
import { URL } from "url";
export default defineComponent({
props: {
privateUrl: {
type: "string",
label: "Notion Private URL",
},
},
async run({ steps }) {
const notionPrivateUrl = new URL(this.privateUrl);
const tasks = steps.list_tasks.$return_value;
console.log("Notion Private URL:", notionPrivateUrl);
console.log("Tasks:", tasks);
const matchingTask = tasks.find((task) => {
if (task.notes) {
try {
const taskUrl = new URL(task.notes);
return taskUrl.pathname === notionPrivateUrl.pathname;
} catch (error) {
console.error("Error parsing URL:", error);
}
}
return false;
});
if (matchingTask) {
console.log("Matching Task:", matchingTask);
return { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: true };
} else {
console.log("No matching task found");
return { taskFound: false };
}
},
});
Logs: Notion Private URL: URL {
href: ‘Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.’,
origin: ‘https://www.notion.so’,
protocol: ‘https:’,
username: ‘’,
password: ‘’,
host: ‘www.notion.so’,
hostname: ‘www.notion.so’,
port: ‘’,
pathname: ‘/Third-task-creation-e8ff9c464cce44b38eecc3392ffdfae8’,
search: ‘’,
searchParams: URLSearchParams {},
hash: ‘’
}
I see the issue in your code. It appears that the greater than symbol (>
) is encoded as >
in the arrow function within the tasks.find()
method. Please replace >
with >
and try running the code again. Here’s the corrected code snippet: ```
const matchingTask = tasks.find((task) => { if (task.notes) { try { const taskUrl = new URL(task.notes); return taskUrl.pathname === notionPrivateUrl.pathname; } catch (error) { console.error(“Error parsing URL:”, error); } } return false; });
more logs: Error parsing URL: at null.__node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at null.NodeError (node:internal/errors:405:5)
at null.URL (node:internal/url:611:13)
at null.null (file:///tmp/pdg/dist/code/5b4e4f6f6fad52ceffa365dec43b72a2b5ad66012f162c15532cd97dd74c393f/component.mjs:20:27)
at Array.find (null:null:null)
at Object.run (file:///tmp/pdg/dist/code/5b4e4f6f6fad52ceffa365dec43b72a2b5ad66012f162c15532cd97dd74c393f/component.mjs:17:32)
at null.executeComponent (/var/task/launch_worker.js:229:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
{
input: ‘zap https://www.notion.so/Updating-Church-Insurance-6693a2b771ec4cd38b1fc9a84ff589b8 (pastoradam)’,
code: ‘ERR_INVALID_URL’
}
Error parsing URL: at null.__node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at null.NodeError (node:internal/errors:405:5)
at null.URL (node:internal/url:611:13)
at null.null (file:///tmp/pdg/dist/code/5b4e4f6f6fad52ceffa365dec43b72a2b5ad66012f162c15532cd97dd74c393f/component.mjs:20:27)
at Array.find (null:null:null)
at Object.run (file:///tmp/pdg/dist/code/5b4e4f6f6fad52ceffa365dec43b72a2b5ad66012f162c15532cd97dd74c393f/component.mjs:17:32)
at null.executeComponent (/var/task/launch_worker.js:229:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
{
input: ‘zap https://www.notion.so/Generosity-Plan-451e3fa48eae4ec99e41cd7e9ca77ae2 (pastoradam)’,
code: ‘ERR_INVALID_URL’
}
Error parsing URL: at null.__node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at null.NodeError (node:internal/errors:405:5)
at null.URL (node:internal/url:611:13)
at null.null (file:///tmp/pdg/dist/code/5b4e4f6f6fad52ceffa365dec43b72a2b5ad66012f162c15532cd97dd74c393f/component.mjs:20:27)
at Array.find (null:null:null)
at Object.run (file:///tmp/pdg/dist/code/5b4e4f6f6fad52ceffa365dec43b72a2b5ad66012f162c15532cd97dd74c393f/component.mjs:17:32)
at null.executeComponent (/var/task/launch_worker.js:229:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
{
input: ‘Hi there!\n’ +
‘\n’ +
‘Thanks for setting up the Reclaim / Google Tasks integration.\n’ +
‘\n’ +
‘You can tell Reclaim when to schedule the task and for how long by using the following command style:\n’ +
‘\n’ +
‘[Task Name] (type:work-or-personal, duration:mins-or-hours, due:date, notbefore:date\n’ +
‘\n’ +
For example, to create a personal task called "Eat Bananas" for 1 hour due next week starting no earlier than tomorrow, you'd type:\n
+
‘\n’ +
‘Eat Bananas (type:personal, duration:1h, due:next week, notbefore:tomorrow)\n’ +
‘\n’ +
‘You can watch a short video on how to use the integration here: https://www.youtube.com/watch?v=1fG1NBCE7xM&feature=youtu.be\n’ +
‘\n’ +
‘Happy Tasking!’,
code: ‘ERR_INVALID_URL’
}
I’m sorry you’re experiencing issues with URL parsing. It seems like there’s an error in the code. To help you further, can you please provide more information about the code you’re using and what you’re trying to achieve? This will help me understand the issue better and provide a solution.
Here’s the code: import { URL } from “url”;
export default defineComponent({
props: {
privateUrl: {
type: “string”,
label: “Notion Private URL”,
},
},
async run({ steps }) {
const notionPrivateUrl = new URL(this.privateUrl);
const tasks = steps.list_tasks.$return_value;
console.log("Notion Private URL:", notionPrivateUrl);
console.log("Tasks:", tasks);
**const** matchingTask = tasks.find((task) => {
**if** (task.notes) {
**try** {
**const** taskUrl = **new** URL(task.notes);
**return** taskUrl.pathname === notionPrivateUrl.pathname;
} **catch** (error) {
console.error("Error parsing URL:", error);
}
}
**return** **false**;
});
**if** (matchingTask) {
console.log("Matching Task:", matchingTask);
**return** { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: **true** };
} **else** {
console.log("No matching task found");
**return** { taskFound: **false** };
}
},
});
I see that you’re trying to find a matching task based on the URL pathname. There’s a small issue with the code: you’re using >
instead of >
in the arrow function. Here’s the corrected code: ```
import { URL } from “url”; export default defineComponent({ props: { privateUrl: { type: “string”, label: “Notion Private URL”, }, }, async run({ steps }) { const notionPrivateUrl = new URL(this.privateUrl); const tasks = steps.list_tasks.$return_value; console.log(“Notion Private URL:”, notionPrivateUrl); console.log(“Tasks:”, tasks); const matchingTask = tasks.find((task) => { if (task.notes) { try { const taskUrl = new URL(task.notes); return taskUrl.pathname === notionPrivateUrl.pathname; } catch (error) { console.error(“Error parsing URL:”, error); } } return false; }); if (matchingTask) { console.log(“Matching Task:”, matchingTask); return { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: true }; } else { console.log(“No matching task found”); return { taskFound: false }; } }, });
THe logs are still showing the exact some issue at parsing the url
I apologize for the confusion earlier. I’ve taken another look at your code and noticed that the issue might be related to the URL parsing itself. The url
module you’re importing at the beginning is not necessary in this case, as it’s a built-in module in Node.js. You can simply use the URL
constructor directly. Here’s the updated code: ```
export default defineComponent({ props: { privateUrl: { type: “string”, label: “Notion Private URL”, }, }, async run({ steps }) { const notionPrivateUrl = new URL(this.privateUrl); const tasks = steps.list_tasks.$return_value; console.log(“Notion Private URL:”, notionPrivateUrl); console.log(“Tasks:”, tasks); const matchingTask = tasks.find((task) => { if (task.notes) { try { const taskUrl = new URL(task.notes); return taskUrl.pathname === notionPrivateUrl.pathname; } catch (error) { console.error(“Error parsing URL:”, error); } } return false; }); if (matchingTask) { console.log(“Matching Task:”, matchingTask); return { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: true }; } else { console.log(“No matching task found”); return { taskFound: false }; } }, });
The issues with the URL parsing seem to happen only when the node doesn’t find a matching task.
I see. In that case, let’s add a check to ensure that the task notes contain a valid URL before attempting to parse it. This should help avoid issues when a matching task is not found. Here’s the updated code: ```
export default defineComponent({ props: { privateUrl: { type: “string”, label: “Notion Private URL”, }, }, async run({ steps }) { const notionPrivateUrl = new URL(this.privateUrl); const tasks = steps.list_tasks.$return_value; console.log(“Notion Private URL:”, notionPrivateUrl); console.log(“Tasks:”, tasks); const matchingTask = tasks.find((task) => { if (task.notes && task.notes.startsWith(“http”)) { try { const taskUrl = new URL(task.notes); return taskUrl.pathname === notionPrivateUrl.pathname; } catch (error) { console.error(“Error parsing URL:”, error); } } return false; }); if (matchingTask) { console.log(“Matching Task:”, matchingTask); return { taskId: matchingTask.id, taskTitle: matchingTask.title, taskFound: true }; } else { console.log(“No matching task found”); return { taskFound: false }; } }, });
This code should be checking if a task needs to be created in google task by looking at the previous code, checking if matching task is found. But it doesn’t seem to be working right for some reason. The log says Checking_if_Matching_Task_is_Found output: { taskFound: undefined } This is the code:
export default defineComponent({
async run({ steps }) {
const taskFound = steps.Checking_if_Matching_Task_is_Found.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** };
}
},
});
It seems like the steps.Checking_if_Matching_Task_is_Found.taskFound
might not be returning the expected value. To debug this issue, let’s add a console.log
statement to log the entire steps.Checking_if_Matching_Task_is_Found
object. This will help us understand if the issue is with the taskFound
property or the step itself. Here’s the updated code: export default defineComponent({ async run({ steps }) { console.log("Checking_if_Matching_Task_is_Found step:", steps.Checking_if_Matching_Task_is_Found); const taskFound = steps.Checking_if_Matching_Task_is_Found.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 }; } }, });
Please try running this updated code and check the logs for the output of the steps.Checking_if_Matching_Task_is_Found
object. If you still encounter any issues, please let me know.