{"record":{"id":"d28bd8fc762915a2","repo":"Mintplex-Labs/anything-llm","slug":"invalid-period-period-use-today-tomorro","errorCode":null,"errorMessage":"Invalid period: \"${period}\". Use \"today\", \"tomorrow\", \"week\", \"this week\", \"next week\", \"month\", \"this month\", or \"next month\".","messagePattern":"Invalid period: \"(.+?)\"\\. Use \"today\", \"tomorrow\", \"week\", \"this week\", \"next week\", \"month\", \"this month\", or \"next month\"\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/google-calendar/events/gcal-get-upcoming-events.js","lineNumber":66,"sourceCode":"    case \"this month\":\n      startDate = new Date(today);\n      endDate = new Date(today);\n      endDate.setDate(endDate.getDate() + 30);\n      endDate.setHours(23, 59, 59, 999);\n      label = \"the next 30 days\";\n      break;\n\n    case \"next month\":\n      startDate = new Date(today);\n      startDate.setDate(startDate.getDate() + 30);\n      endDate = new Date(startDate);\n      endDate.setDate(endDate.getDate() + 30);\n      endDate.setHours(23, 59, 59, 999);\n      label = \"next month\";\n      break;\n\n    default:\n      throw new Error(\n        `Invalid period: \"${period}\". Use \"today\", \"tomorrow\", \"week\", \"this week\", \"next week\", \"month\", \"this month\", or \"next month\".`\n      );\n  }\n\n  return {\n    startDate: startDate.toISOString(),\n    endDate: endDate.toISOString(),\n    label,\n  };\n}\n\nmodule.exports.GCalGetUpcomingEvents = {\n  name: \"gcal-get-upcoming-events\",\n  plugin: function () {\n    return {\n      name: \"gcal-get-upcoming-events\",\n      setup(aibitat) {\n        aibitat.function({","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/agents/aibitat/plugins/google-calendar/events/gcal-get-upcoming-events.js#L48-L84","documentation":"Thrown by the default branch of the period switch in GCalGetUpcomingEvents when the period argument is not one of the eight supported strings: today, tomorrow, week, this week, next week, month, this month, next month. The message enumerates the allowed values, so the fix is always to normalize the caller's input to that vocabulary. It is plain enum validation on an LLM-supplied tool argument.","triggerScenarios":"Agent passes 'this weekend', 'next 7 days', 'year', 'this quarter', or an empty string as period; user phrasing is copied verbatim instead of mapped to a supported bucket; a locale difference (' Cette semaine') reaches the tool unmapped.","commonSituations":"LLM free-forming the period instead of using the enum; prompt updates that rename the parameter vocabulary; multi-word variants like 'the week' slipping through a thin wrapper.","solutions":["Map free-form input to the closest supported value before invoking the tool (e.g. 'this weekend' -> 'week', 'next 30 days' -> 'next month').","Constrain the agent with a tool schema/enum listing exactly the eight strings so the model cannot emit anything else.","Default to 'this week' when input is unrecognized instead of letting the error propagate to the agent turn."],"exampleFix":"// before\ngcal_get_upcoming_events({ period: \"this weekend\" })  // throws\n\n// after\nconst SUPPORTED = [\"today\",\"tomorrow\",\"week\",\"this week\",\"next week\",\"month\",\"this month\",\"next month\"];\nconst period = SUPPORTED.includes(input) ? input : \"this week\";\ngcal_get_upcoming_events({ period });","handlingStrategy":"validation","validationCode":"const SUPPORTED_PERIODS = [\"today\", \"tomorrow\", \"week\", \"this week\", \"next week\", \"month\", \"this month\", \"next month\"];\nfunction normalizePeriod(input) {\n  const p = String(input ?? \"\").trim().toLowerCase();\n  return SUPPORTED_PERIODS.includes(p) ? p : \"this week\"; // safe default instead of throw\n}","typeGuard":"/** @param {unknown} v @returns {boolean} */\nfunction isSupportedPeriod(v) {\n  return typeof v === \"string\" && SUPPORTED_PERIODS.includes(v.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  const range = getCalendarDuration(period);\n} catch (e) {\n  if (e.message.startsWith(\"Invalid period:\")) {\n    range = getCalendarDuration(\"this week\"); // fall back to a supported bucket\n  } else throw e;\n}","preventionTips":["Declare the period parameter as an enum in the tool schema so the model can only emit valid values.","Normalize user phrasing to the eight supported buckets before calling the tool.","Add new period strings to the switch AND the error message together so docs stay accurate."],"tags":["google-calendar","enum-validation","agent-tools","date-range"],"backgroundTag":"enum-validation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}