{"record":{"id":"3f3e2d8cea7a903e","repo":"hoppscotch/hoppscotch","slug":"json-schema-validation-is-not-available-in-this-en","errorCode":null,"errorMessage":"JSON schema validation is not available in this environment. To use this feature, please enable the experimental scripting sandbox or upgrade to a supported version of Hoppscotch that includes JSON schema validation support.","messagePattern":"JSON schema validation is not available in this environment\\. To use this feature, please enable the experimental scripting sandbox or upgrade to a supported version of Hoppscotch that includes JSON schema validation support\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/hoppscotch-js-sandbox/src/bootstrap-code/post-request.js","lineNumber":3442,"sourceCode":"          responseTime: {\n            below: (ms) => {\n              const actual = globalThis.hopp.response.responseTime\n              globalThis.hopp.expect(actual).to.be.below(ms)\n            },\n            above: (ms) => {\n              const actual = globalThis.hopp.response.responseTime\n              globalThis.hopp.expect(actual).to.be.above(ms)\n            },\n          },\n          jsonSchema: (schema) => {\n            // Manual jsonSchema validation with Postman-compatible messages\n            // Delegates to external AJV-based validator provided via inputs.validateJsonSchema\n            // This matches Postman's behavior: record assertion but don't throw\n            const jsonData = globalThis.hopp.response.body.asJSON()\n\n            // Validate schema\n            if (!inputs.validateJsonSchema) {\n              throw new Error(\n                \"JSON schema validation is not available in this environment. To use this feature, please enable the experimental scripting sandbox or upgrade to a supported version of Hoppscotch that includes JSON schema validation support.\"\n              )\n            }\n            const validation = inputs.validateJsonSchema(jsonData, schema)\n\n            // Record result with Postman-compatible message using helper\n            if (inputs.pushExpectResult) {\n              const status = validation.isValid ? \"pass\" : \"fail\"\n              const message = validation.isValid\n                ? \"Response body matches JSON schema\"\n                : validation.errorMessage || \"Schema validation failed\"\n              inputs.pushExpectResult(status, message)\n            }\n          },\n          charset: (expectedCharset) => {\n            const headers = globalThis.hopp.response.headers\n            const contentType = headers.find(\n              (h) => h.key.toLowerCase() === \"content-type\"","sourceCodeStart":3424,"sourceCodeEnd":3460,"githubUrl":"https://github.com/hoppscotch/hoppscotch/blob/1acb8a3a7581e4db32ba0d529170c4669a2e1053/packages/hoppscotch-js-sandbox/src/bootstrap-code/post-request.js#L3424-L3460","documentation":"Thrown by the `pm.expect(...).to.be.jsonSchema(schema)` BDD assertion (post-request.js:3442) when the host did not provide `inputs.validateJsonSchema`. The message instructs enabling the experimental scripting sandbox or upgrading Hoppscotch, because AJV-based validation is injected from outside the QuickJS sandbox (it cannot be bundled inside).","triggerScenarios":"Calling `pm.expect(jsonData).to.be.jsonSchema({...})` or the `response.to.have.jsonSchema(...)` helper when the runtime inputs object lacks `validateJsonSchema`. Common when running scripts in the default (non-experimental) sandbox or an older Hoppscotch build.","commonSituations":"Copying a Postman collection that uses `tv4`/AJV JSON-schema assertions into Hoppscotch without enabling the experimental sandbox. CI/automated runs against a host that strips the `validateJsonSchema` input. Hoppscotch version predating the JSON-schema integration.","solutions":["Enable the experimental scripting sandbox in Hoppscotch so the AJV validator is injected.","Upgrade Hoppscotch to a version that ships JSON-schema validation support.","Replace the schema assertion with manual field checks: `pm.expect(data.id).to.be.a('number')`, etc.","Feature-detect before using: `if (typeof inputs !== 'undefined' && inputs.validateJsonSchema) { ... } else { /* manual */ }`."],"exampleFix":"// before\npm.expect(pm.response.json()).to.be.jsonSchema({ type: 'object', required: ['id'] })\n// after (no schema validator available)\nconst data = pm.response.json()\npm.expect(data).to.be.an('object')\npm.expect(data.id).to.not.be.undefined","handlingStrategy":"validation","validationCode":"// Feature-detect before using JSON-schema assertions\nfunction hasJsonSchemaValidator() {\n  try {\n    return typeof inputs !== 'undefined' && typeof inputs.validateJsonSchema === 'function'\n  } catch (_) {\n    return false\n  }\n}\nif (hasJsonSchemaValidator()) {\n  pm.expect(pm.response.json()).to.be.jsonSchema({ type: 'object', required: ['id'] })\n} else {\n  const data = pm.response.json()\n  pm.expect(data).to.be.an('object')\n  pm.expect(data.id).to.not.be.undefined\n}","typeGuard":"/** True when the host injected a JSON-schema validator. */\nfunction jsonSchemaAvailable() {\n  try { return typeof inputs.validateJsonSchema === 'function' } catch (_) { return false }\n}","tryCatchPattern":"try {\n  pm.expect(pm.response.json()).to.be.jsonSchema(schema)\n} catch (e) {\n  if (e.message.startsWith('JSON schema validation is not available')) {\n    console.warn('schema validator missing; enable experimental sandbox or assert manually')\n  }\n  throw e\n}","preventionTips":["Enable the experimental scripting sandbox so AJV is injected.","Feature-detect `inputs.validateJsonSchema` before using `.to.be.jsonSchema`.","Keep manual field checks as a fallback for environments without the validator.","Upgrade Hoppscotch to a build that ships JSON-schema support."],"tags":["json-schema","ajv","feature-unavailable","postman-compat","experimental"],"backgroundTag":null,"analyzedSha":"1acb8a3a7581e4db32ba0d529170c4669a2e1053","analyzedAt":"2026-08-12T11:34:52.648Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}