You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting the below error when executing the basic example provided in the docs in my NodeJs project:
/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/index.js:120
throw e;
^
Error: strict mode: unknown keyword: "afterRequest"
at checkStrictMode (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/util.js:174:15)
at checkUnknownRules (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/util.js:32:13)
at checkKeywords (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/validate/index.js:120:34)
at validateFunctionCode (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/validate/index.js:19:9)
at Ajv.compileSchema (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/index.js:80:45)
at Ajv.resolveSchema (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/compile/index.js:193:23)
at Ajv.getSchema (/Users/harsh/Desktop/http-snippet-demo/node_modules/ajv/dist/core.js:279:43)
at validateHarRequest (/Users/harsh/Desktop/http-snippet-demo/node_modules/httpsnippet/dist/helpers/har-validator.js:66:24)
at /Users/harsh/Desktop/http-snippet-demo/node_modules/httpsnippet/dist/httpsnippet.js:262:56
at Array.forEach (<anonymous>)
httpsnippet version in package.json file: ^3.0.1
NodeJs version: 18.17
I am getting the same error via CLI as well when executing the below command: httpsnippet example.json --target shell --client curl --output ./examples
@austineady@Harsh062 I believe you're getting this error because the version of the ajv you're using is 8 while version 6 is needed for httpsnippet. If you do downgrade to 6, the error should go away. Interestingly enough, ajv is not defined as dep for httpsnippet while it's been used. It's only defined as dependency within har-schema, and I' guessing ajv v8 has some breaking changes.
Activity
austineady commentedon Feb 6, 2024
Seeing the same issue with Node v20.10.0. Only reference to
afterRequestI can find is within thehar-schemapackage.mattvalleycodes commentedon Apr 10, 2024
@austineady @Harsh062 I believe you're getting this error because the version of the
ajvyou're using is8while version6is needed forhttpsnippet. If you do downgrade to6, the error should go away. Interestingly enough,ajvis not defined as dep forhttpsnippetwhile it's been used. It's only defined as dependency withinhar-schema, and I' guessingajv v8has some breaking changes.vaibhavrajsingh2001 commentedon Oct 16, 2024
@Harsh062 @austineady you shouldn't face this error anymore from v3.0.7 onwards.
Fixed as part of #371.