{"record":{"id":"97e0486126ae8d18","repo":"mozilla/pdf.js","slug":"app-formsversion-is-read-only","errorCode":null,"errorMessage":"app.formsVersion is read-only","messagePattern":"app\\.formsVersion is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/app.js","lineNumber":230,"sourceCode":"  set constants(_) {\n    throw new Error(\"app.constants is read-only\");\n  }\n\n  get focusRect() {\n    return this._focusRect;\n  }\n\n  set focusRect(val) {\n    /* TODO or not */\n    this._focusRect = val;\n  }\n\n  get formsVersion() {\n    return FORMS_VERSION;\n  }\n\n  set formsVersion(_) {\n    throw new Error(\"app.formsVersion is read-only\");\n  }\n\n  get fromPDFConverters() {\n    return [];\n  }\n\n  set fromPDFConverters(_) {\n    throw new Error(\"app.fromPDFConverters is read-only\");\n  }\n\n  get fs() {\n    return (this._fs ??= new Proxy(\n      new FullScreen({ send: this._send }),\n      this._proxyHandler\n    ));\n  }\n\n  set fs(_) {","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/app.js#L212-L248","documentation":"app.formsVersion exposes the compiled FORMS_VERSION constant of the viewer. It is informational and fixed per PDF.js build, so the setter always throws. The throw indicates an attempt to spoof or override the reported forms engine version.","triggerScenarios":"Any assignment app.formsVersion = <value> in PDF-embedded JS or scripting-API test code hits the unconditional throw at src/scripting_api/app.js:230.","commonSituations":"Scripts trying to fake a higher forms-version to unlock features; conditional logic that mistakenly writes instead of reads the property.","solutions":["Read app.formsVersion only (e.g. for feature gating by comparison).","Gate features on your own capability flags rather than rewriting the version.","If you need a different forms version, build PDF.js from the matching source tag."],"exampleFix":"// before\napp.formsVersion = 999;\n// after\nif (app.formsVersion >= FORMS_VERSION) { /* supported */ }","handlingStrategy":"validation","validationCode":"// formsVersion is a build constant; read only.\nconst supported = (app) => typeof app.formsVersion === 'number';","typeGuard":"const isNumberConstant = (v) => typeof v === 'number' && Number.isFinite(v);","tryCatchPattern":"try { /* code that may assign app.formsVersion */ }\ncatch (e) { if (!/formsVersion is read-only/.test(e.message)) throw e; }","preventionTips":["Feature-gate by reading formsVersion, never by writing it.","Pin your PDF.js build version to know which formsVersion to expect.","Document the expected constant in your integration notes."],"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"}