jackwener/OpenCLI · error · ArgumentError
unsupported notification type: ${value}
Error message
unsupported notification type: ${value} What it means
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, ...).
Source
Thrown at clis/tiktok/utils.js:69
'username contains unsupported characters',
'Pass the TikTok handle without @, for example: dictogo',
);
}
return username;
}
export const NOTIFICATION_TYPES = {
all: { code: 0, label: 'all' },
likes: { code: 3, label: 'likes' },
comments: { code: 7, label: 'comments' },
mentions: { code: 6, label: 'mentions' },
followers: { code: 4, label: 'followers' },
};
export function requireNotificationType(value) {
const key = String(value ?? 'all').trim().toLowerCase();
if (!Object.prototype.hasOwnProperty.call(NOTIFICATION_TYPES, key)) {
throw new ArgumentError(
`unsupported notification type: ${value}`,
`Allowed: ${Object.keys(NOTIFICATION_TYPES).join(', ')}`,
);
}
return key;
}
// Comment text bound: TikTok rejects long comments at submit time.
// We validate length + non-empty up-front so the adapter never tries to
// paste an empty / overlong string into the contenteditable input.
export const COMMENT_TEXT_MAX = 150;
export function requireCommentText(value) {
const text = String(value ?? '').trim();
if (!text) {
throw new ArgumentError(
'comment text is required',
'Example: opencli tiktok comment <url> "great video"',View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before opencli tiktok notifications someone --type follower // after opencli tiktok notifications someone --type followers
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED_TYPES = ['all', 'followers' /* ...match NOTIFICATION_TYPES keys in utils.js */];
function assertType(v) {
const key = String(v ?? 'all').trim().toLowerCase();
if (!ALLOWED_TYPES.includes(key)) throw new Error(`unsupported notification type: ${v}; allowed: ${ALLOWED_TYPES.join(', ')}`);
return key;
}
assertType(typeFlag); Try / catch
try {
await cli.tiktok.notifications(username, { type });
} catch (e) {
const m = /Allowed: (.+)/.exec(e.message);
if (m) console.error(`Bad --type '${type}'. Allowed: ${m[1]}`);
else throw e;
} Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- ${label} must be one of: ${Object.keys(choices).join(', ')}
- ${label} must be one of: ${choices.join(', ')}
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/56139c9d7e6f5465.
Report an issue: GitHub.