{"record":{"id":"6e9664de07125242","repo":"mozilla/pdf.js","slug":"app-viewervariation-is-read-only","errorCode":null,"errorMessage":"app.viewerVariation is read-only","messagePattern":"app\\.viewerVariation is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/app.js","lineNumber":396,"sourceCode":"  set toolbarVertical(value) {\n    /* has been deprecated and it's now equivalent to toolbar */\n    this.toolbar = value;\n  }\n\n  get viewerType() {\n    return VIEWER_TYPE;\n  }\n\n  set viewerType(_) {\n    throw new Error(\"app.viewerType is read-only\");\n  }\n\n  get viewerVariation() {\n    return VIEWER_VARIATION;\n  }\n\n  set viewerVariation(_) {\n    throw new Error(\"app.viewerVariation is read-only\");\n  }\n\n  get viewerVersion() {\n    return VIEWER_VERSION;\n  }\n\n  set viewerVersion(_) {\n    throw new Error(\"app.viewerVersion is read-only\");\n  }\n\n  addMenuItem() {\n    /* Not implemented */\n  }\n\n  addSubMenu() {\n    /* Not implemented */\n  }\n","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/app.js#L378-L414","documentation":"app.viewerVariation exposes the compiled VIEWER_VARIATION constant. It is a fixed per-build value and the setter throws to enforce read-only semantics. Assignment is rejected unconditionally.","triggerScenarios":"Any assignment app.viewerVariation = <value> in PDF JavaScript or caller code hits the throw at src/scripting_api/app.js:396.","commonSituations":"Scripts trying to fake a SKU variation; authors confusing the constant with a configurable option.","solutions":["Read app.viewerVariation only.","Use the constant for capability detection rather than reassignment.","Build PDF.js from source if a non-default variation is required."],"exampleFix":"// before\napp.viewerVariation = 'Pro';\n// after\nconst v = app.viewerVariation; // read-only","handlingStrategy":"validation","validationCode":"// app.viewerVariation is a build constant; read only.\nconst variation = app.viewerVariation;","typeGuard":"const isNonEmptyString = (v) => typeof v === 'string' && v.length > 0;","tryCatchPattern":"try { /* code that may assign app.viewerVariation */ }\ncatch (e) { if (!/viewerVariation is read-only/.test(e.message)) throw e; }","preventionTips":["Use the constant for capability detection.","Never try to spoof a SKU variation from document JS.","Rebuild from source to change the value."],"tags":["scripting-api","read-only","version","acrobat-js"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}