{"record":{"id":"b484958f2eab0f7e","repo":"jackwener/OpenCLI","slug":"flathub-appid-is-required-e-g-org-mozilla-firef","errorCode":null,"errorMessage":"flathub appId is required (e.g. \"org.mozilla.firefox\")","messagePattern":"flathub appId is required \\(e\\.g\\. \"org\\.mozilla\\.firefox\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/flathub/utils.js","lineNumber":37,"sourceCode":"    if (!s) throw new ArgumentError(`flathub ${label} cannot be empty`);\n    return s;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\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(`flathub ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`flathub ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireAppId(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) throw new ArgumentError('flathub appId is required (e.g. \"org.mozilla.firefox\")');\n    if (!APP_ID_PATTERN.test(raw)) {\n        throw new ArgumentError(\n            `flathub appId \"${value}\" is not a valid AppStream identifier`,\n            'AppStream IDs use reverse-DNS like \"org.mozilla.firefox\" — letters/digits/`._-` with at least one dot.',\n        );\n    }\n    return raw;\n}\n\nexport async function flathubFetch(url, label, init) {\n    let resp;\n    try {\n        resp = await fetch(url, {\n            method: init?.method ?? 'GET',\n            headers: { 'user-agent': UA, accept: 'application/json', ...(init?.headers ?? {}) },\n            body: init?.body,\n        });\n    }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/flathub/utils.js#L19-L55","documentation":"requireAppId validates the Flathub appId argument and throws ArgumentError 'flathub appId is required (e.g. \"org.mozilla.firefox\")' when the value is empty after trimming. The library throws this early because every app-detail lookup requires a non-empty AppStream ID to build the API URL.","triggerScenarios":"Calling an adapter that calls requireAppId(value) with null, undefined, '', or whitespace, e.g. `flathub info` with no appId argument, or requireAppId(env.APP_ID) with the variable unset.","commonSituations":"CLI invoked without the positional appId; shell variable unset or empty when interpolated; piping an empty line into a script; copy-paste losing the argument.","solutions":["Pass a valid appId such as org.mozilla.firefox","Find the exact ID via `flathub search <name>` and use its appId field","Check that the shell variable feeding the argument is set and exported","Default the value in your script and fail with a clear message before calling"],"exampleFix":"// before\nconst id = process.argv[3]; // missing\nawait appInfo(id);\n// after\nconst id = process.argv[3];\nif (!id) {\n  console.error('usage: flathub info <appId>  e.g. org.mozilla.firefox');\n  process.exit(2);\n}\nawait appInfo(id);","handlingStrategy":"validation","validationCode":"const id = (appId ?? '').trim();\nif (!id) throw new Error('appId is required, e.g. org.mozilla.firefox');","typeGuard":"function hasAppId(args) {\n  return typeof args.appId === 'string' && args.appId.trim().length > 0;\n}","tryCatchPattern":"try {\n  await appInfo(appId);\n} catch (err) {\n  if (err instanceof ArgumentError && err.message.includes('appId is required')) {\n    console.error('usage: flathub info <appId>  e.g. org.mozilla.firefox');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Make appId a required positional argument in your CLI parser","Resolve ambiguous names via `flathub search` first, then use the returned appId","Guard shell variables feeding the argument (${APP_ID:?missing})","Fail early in scripts when the argument is missing rather than mid-run"],"tags":["argument-validation","missing-argument","appstream-id"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}