{"record":{"id":"152df48468fa2adf","repo":"jackwener/OpenCLI","slug":"medium-tag-is-required-e-g-programming-javas","errorCode":null,"errorMessage":"medium tag is required (e.g. \"programming\", \"javascript\")","messagePattern":"medium tag is required \\(e\\.g\\. \"programming\", \"javascript\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/medium/tag.js","lineNumber":54,"sourceCode":"    }\n    return out;\n}\n\nfunction isoDateFromRfc822(value) {\n    if (!value) return '';\n    const d = new Date(value);\n    if (Number.isNaN(d.getTime())) return '';\n    return d.toISOString().slice(0, 10);\n}\n\nfunction stripHtml(value) {\n    return decodeHtml(String(value ?? '').replace(/<[^>]+>/g, ' ').replace(/\\s+/g, ' ').trim());\n}\n\nfunction requireTag(value) {\n    const s = String(value ?? '').trim().toLowerCase();\n    if (!s) {\n        throw new ArgumentError('medium tag is required (e.g. \"programming\", \"javascript\")');\n    }\n    if (!TAG_PATTERN.test(s)) {\n        throw new ArgumentError(\n            `medium tag \"${value}\" is not valid`,\n            'Tags are lowercase alphanumeric, optionally hyphenated (e.g. \"machine-learning\").',\n        );\n    }\n    return s;\n}\n\nfunction requireBoundedInt(value, defaultValue, maxValue) {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError('medium limit must be a positive integer');\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`medium limit must be <= ${maxValue}`);","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/medium/tag.js#L36-L72","documentation":"requireTag validates the tag argument for the medium tag command. An empty (missing/null/whitespace) tag throws this ArgumentError, which explicitly shows example tags. Medium commands require a tag to operate on.","triggerScenarios":"Running the medium tag command without the tag argument; passing an unset shell variable; passing '' or '   '.","commonSituations":"Forgetting the positional argument in scripts; environment variables that failed to expand; copying a command template without filling in the tag.","solutions":["Pass a tag, e.g. medium tag programming or medium tag javascript.","Check that the shell variable holding the tag is set before invoking.","Add a usage check in wrapper scripts before calling the command.","Quote the argument if it may contain hyphens or spaces: \"machine-learning\"."],"exampleFix":"// before\nTAG=\"\"; opencli medium tag \"$TAG\"\n// after\nTAG=\"${TAG:-}\"\nif [ -z \"$TAG\" ]; then echo 'usage: medium tag <tag>'; exit 2; fi\nopencli medium tag \"$TAG\"","handlingStrategy":"validation","validationCode":"const tag = (value ?? '').trim().toLowerCase();\nif (!tag) throw new TypeError('medium tag is required');","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { await mediumTag(tag); } catch (e) { if (String(e.message).includes('tag is required')) { printUsage(); process.exitCode = 2; return; } throw e; }","preventionTips":["Validate required positional args before dispatching commands","Guard shell variables with ${VAR:?} to fail on unset","Provide default tags in wrapper scripts where sensible"],"tags":["validation","argument-error","cli"],"backgroundTag":"empty-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}