{"record":{"id":"d157f7d1d0d45c5c","repo":"Zie619/n8n-workflows","slug":"no-todoist-section-found-for-status-statusname","errorCode":null,"errorMessage":"No Todoist section found for status '${statusName}'","messagePattern":"No Todoist section found for status '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/Webhook/1897_Webhook_Filter_Sync_Webhook.json","lineNumber":896,"sourceCode":"              \"value\": \"={{ $json.section_id }}\"\n            }\n          ]\n        }\n      },\n      \"typeVersion\": 3.4,\n      \"notes\": \"This set node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"283370f2-93ff-4272-82bf-ad45c54e47f7\",\n      \"name\": \"Map Notion to Todoist\",\n      \"type\": \"n8n-nodes-base.code\",\n      \"position\": [\n        3200,\n        400\n      ],\n      \"parameters\": {\n        \"mode\": \"runOnceForEachItem\",\n        \"jsCode\": \"const globals = $('Globals').first().json;\\nconst properties = $json.properties;\\n\\nlet output = {};\\n\\noutput.id = properties['Todoist ID'].rich_text.length > 0 ? \\n  properties['Todoist ID'].rich_text[0].text.content : \\n  null;\\n\\noutput.content = properties['Name'].title.length > 0 ? properties['Name'].title[0].text.content : '[empty]';\\n\\noutput.description = \\\"[↗ Open in Notion](\\\" + $json.url + \\\")\\\"\\n\\n// Map priority\\nif (properties['Priority'].select === null) {\\n  output.priority = \\\"1\\\"; // P4\\n} else {\\n  output.priority = {\\n    \\\"do first\\\": \\\"4\\\", // P1\\n    \\\"urgent\\\": \\\"3\\\", // P2\\n    \\\"important\\\": \\\"2\\\" // P3\\n  }[properties['Priority'].select.name] ?? \\\"1\\\"; // P4\\n}\\n\\n// Map section\\nconst statusName = properties['Status'].status.name;\\noutput.section_id = null;\\nif (!['Done', 'Obsolete'].includes(statusName)) {\\n  const sectionMap = Object.fromEntries(\\n      globals.sections.map(section => [section.name, section.id])\\n  );\\n  if (!sectionMap.hasOwnProperty(statusName)) {\\n      throw new Error(\\\"No Todoist section found for status '\\\" + statusName + \\\"'\\\");\\n  }\\n  output.section_id = sectionMap[statusName];\\n}\\n\\n// Set UTC if time is set\\noutput.due_datetime = null;\\nif (properties['Due'].date !== null) {\\n  output.due_datetime = properties.Due.date.start;\\n  if (properties.Due.date.start.length > 10) {\\n    output.due_datetime = new Date(properties.Due.date.start).toISOString();\\n  }\\n}\\n\\nreturn { json: output };\"\n      },\n      \"typeVersion\": 2,\n      \"notes\": \"This code node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"ca33c90f-3204-45e1-9d66-20e7e740a4d7\",\n      \"name\": \"Update task in Todoist before closing\",\n      \"type\": \"n8n-nodes-base.httpRequest\",\n      \"position\": [\n        4540,\n        1120\n      ],\n      \"parameters\": {\n        \"url\": \"{{ $env.BASE_URL }}\",\n        \"method\": \"POST\",\n        \"options\": {},\n        \"jsonQuery\": \"={{ $json.toJsonString() }}\",\n        \"sendQuery\": true,","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Webhook/1897_Webhook_Filter_Sync_Webhook.json#L878-L914","documentation":"Thrown by 'Map Notion to Todoist' (runOnceForEachItem) when a Notion task's Status name (properties['Status'].status.name) has no matching section in globals.sections — the section list fetched earlier from the Todoist project. Done and Obsolete are exempted (no section needed); every other status must exist as a Todoist section by exact name.","triggerScenarios":"A new status added to the Notion database (e.g., 'In Review') without creating the same-named section in the Todoist project, a renamed Notion status ('In Progress' -> 'Doing'), or the Globals node having fetched sections from the wrong project / an incomplete list (pagination, API hiccup).","commonSituations":"Notion databases evolve faster than the Todoist project; teams rename statuses; the Todoist project ID changes so globals.sections is empty or foreign; case/whitespace mismatches ('backlog' vs 'Backlog').","solutions":["Compare the Notion status names with the Todoist project's sections and create the missing section in Todoist (exact name match).","Add a fallback mapping in the code for known renames, or default to a catch-all section instead of throwing.","Verify the Globals node's project_id and that its sections list is complete (check its pinned output).","Include the available section names in the error message for instant diagnosis."],"exampleFix":"// before\nif (!sectionMap.hasOwnProperty(statusName)) {\n    throw new Error(\"No Todoist section found for status '\" + statusName + \"'\");\n}\noutput.section_id = sectionMap[statusName];\n\n// after - explicit fallback with visibility\nconst FALLBACK_SECTION = 'Backlog';\nif (!sectionMap.hasOwnProperty(statusName)) {\n  if (!sectionMap.hasOwnProperty(FALLBACK_SECTION)) {\n    throw new Error(`No Todoist section for status '${statusName}' and no fallback '${FALLBACK_SECTION}'. Known sections: ${Object.keys(sectionMap).join(', ')}`);\n  }\n  console.warn(`Unknown status '${statusName}'; routing to '${FALLBACK_SECTION}'`);\n  output.section_id = sectionMap[FALLBACK_SECTION];\n} else {\n  output.section_id = sectionMap[statusName];\n}","handlingStrategy":"validation","validationCode":"const sectionMap = Object.fromEntries(globals.sections.map(s => [s.name, s.id]));\nconst statusName = properties['Status'].status.name;\nif (!['Done', 'Obsolete'].includes(statusName) && !(statusName in sectionMap)) {\n  // policy choice: fail loudly with full context, or fall back\n  const fallback = sectionMap['Backlog'];\n  if (!fallback) {\n    throw new Error(`No section for '${statusName}'. Known: ${Object.keys(sectionMap).join(', ')}`);\n  }\n  output.section_id = fallback;\n} else {\n  output.section_id = sectionMap[statusName] ?? null;\n}","typeGuard":"const isKnownStatus = (name, sections) =>\n  ['Done', 'Obsolete'].includes(name) ||\n  sections.some(s => s.name === name);","tryCatchPattern":null,"preventionTips":["Keep Notion status options and Todoist section names in exact 1:1 sync; treat adding a Notion status as a two-system change.","Include known section names in the error message so the fix is obvious without opening the workflow.","Validate globals.sections is non-empty right after fetching it — an empty map turns every status into this error."],"tags":["n8n","code-node","notion","todoist","status-mapping","integration-sync"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}