{"record":{"id":"56139c9d7e6f5465","repo":"jackwener/OpenCLI","slug":"unsupported-notification-type-value","errorCode":null,"errorMessage":"unsupported notification type: ${value}","messagePattern":"unsupported notification type: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/tiktok/utils.js","lineNumber":69,"sourceCode":"            'username contains unsupported characters',\n            'Pass the TikTok handle without @, for example: dictogo',\n        );\n    }\n    return username;\n}\n\nexport const NOTIFICATION_TYPES = {\n    all: { code: 0, label: 'all' },\n    likes: { code: 3, label: 'likes' },\n    comments: { code: 7, label: 'comments' },\n    mentions: { code: 6, label: 'mentions' },\n    followers: { code: 4, label: 'followers' },\n};\n\nexport function requireNotificationType(value) {\n    const key = String(value ?? 'all').trim().toLowerCase();\n    if (!Object.prototype.hasOwnProperty.call(NOTIFICATION_TYPES, key)) {\n        throw new ArgumentError(\n            `unsupported notification type: ${value}`,\n            `Allowed: ${Object.keys(NOTIFICATION_TYPES).join(', ')}`,\n        );\n    }\n    return key;\n}\n\n// Comment text bound: TikTok rejects long comments at submit time.\n// We validate length + non-empty up-front so the adapter never tries to\n// paste an empty / overlong string into the contenteditable input.\nexport const COMMENT_TEXT_MAX = 150;\n\nexport function requireCommentText(value) {\n    const text = String(value ?? '').trim();\n    if (!text) {\n        throw new ArgumentError(\n            'comment text is required',\n            'Example: opencli tiktok comment <url> \"great video\"',","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/utils.js#L51-L87","documentation":"requireNotificationType lowercases the input (defaulting to 'all') and checks it against the NOTIFICATION_TYPES table via hasOwnProperty; unknown keys throw this ArgumentError. The CLI accepts only the fixed set of notification categories defined in that map (e.g. all, followers, ...).","triggerScenarios":"Passing a type string not in NOTIFICATION_TYPES, e.g. --type follower (singular), 'comments' when unsupported, or a typo like 'folowers'; passing mixed case is fine (it is lowercased), but extra whitespace inside or unknown slugs are not.","commonSituations":"Guessing category names instead of reading the allowed list in the error hint; older scripts using renamed type keys after a version change; passing codes/numbers (e.g. 4) where slugs are required.","solutions":["Use one of the allowed keys listed in the error's hint (Object.keys(NOTIFICATION_TYPES) joined).","Fix singular/plural mistakes: the map keys are authoritative (e.g. 'followers', not 'follower').","Omit --type to get the default 'all'.","If a key was renamed in a newer version, check the changelog and update scripts."],"exampleFix":"// before\nopencli tiktok notifications someone --type follower\n// after\nopencli tiktok notifications someone --type followers","handlingStrategy":"validation","validationCode":"const ALLOWED_TYPES = ['all', 'followers' /* ...match NOTIFICATION_TYPES keys in utils.js */];\nfunction assertType(v) {\n  const key = String(v ?? 'all').trim().toLowerCase();\n  if (!ALLOWED_TYPES.includes(key)) throw new Error(`unsupported notification type: ${v}; allowed: ${ALLOWED_TYPES.join(', ')}`);\n  return key;\n}\nassertType(typeFlag);","typeGuard":null,"tryCatchPattern":"try {\n  await cli.tiktok.notifications(username, { type });\n} catch (e) {\n  const m = /Allowed: (.+)/.exec(e.message);\n  if (m) console.error(`Bad --type '${type}'. Allowed: ${m[1]}`);\n  else throw e;\n}","preventionTips":["Copy allowed values exactly from the error hint or NOTIFICATION_TYPES in clis/tiktok/utils.js","Watch singular/plural forms ('followers', not 'follower')","Omit --type to accept the default 'all'","Lowercase/trim values programmatically before passing (the CLI does, but be explicit)"],"tags":["validation","argument-error","cli","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}