{"record":{"id":"09747837e6185da2","repo":"sqlmapproject/sqlmap","slug":"function-preprocess-req-in-preprocess-script","errorCode":null,"errorMessage":"function 'preprocess(req)' in preprocess script '%s' had issues in a test run ('%s'). You can find a template script at '%s'","messagePattern":"function 'preprocess\\(req\\)' in preprocess script '(.+?)' had issues in a test run \\('(.+?)'\\)\\. You can find a template script at '(.+?)'","errorType":"exception","errorClass":"SqlmapGenericException","httpStatus":null,"severity":"error","filePath":"lib/core/option.py","lineNumber":1052,"sourceCode":"                try:\n                    function(_urllib.request.Request(\"http://localhost\"))\n                except Exception as ex:\n                    tbMsg = traceback.format_exc()\n\n                    if conf.debug:\n                        dataToStdout(tbMsg)\n\n                    handle, filename = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.PREPROCESS, suffix=\".py\")\n                    os.close(handle)\n\n                    openFile(filename, \"w+\").write(\"#!/usr/bin/env\\n\\ndef preprocess(req):\\n    pass\\n\")\n                    openFile(os.path.join(os.path.dirname(filename), \"__init__.py\"), \"w+\").write(\"pass\")\n\n                    errMsg = \"function 'preprocess(req)' \"\n                    errMsg += \"in preprocess script '%s' \" % script\n                    errMsg += \"had issues in a test run ('%s'). \" % getSafeExString(ex)\n                    errMsg += \"You can find a template script at '%s'\" % filename\n                    raise SqlmapGenericException(errMsg)\n\ndef _setPostprocessFunctions():\n    \"\"\"\n    Loads postprocess function(s) from given script(s)\n    \"\"\"\n\n    if conf.postprocess:\n        for script in re.split(PARAMETER_SPLITTING_REGEX, conf.postprocess):\n            found = False\n            function = None\n\n            script = safeFilepathEncode(script.strip())\n\n            try:\n                if not script:\n                    continue\n\n                if not os.path.exists(script):","sourceCodeStart":1034,"sourceCodeEnd":1070,"githubUrl":"https://github.com/sqlmapproject/sqlmap/blob/0a35b20e3953d341be6c7ac75ccb0b3362540c8d/lib/core/option.py#L1034-L1070","documentation":"As a smoke test, sqlmap calls the discovered preprocess function once with a dummy urllib Request against http://localhost. If that call raises, sqlmap writes a minimal template script to a temp file, prints its path, and raises this error telling the user the test run failed — i.e., the function may import fine but crashes on a representative Request object (wrong attribute access, unhandled exception, bad return type).","triggerScenarios":"Thrown at lib/core/option.py:1052 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rerun with --debug so the full traceback of the failing test invocation is printed to stdout.","Fix the preprocess function so it handles a standard urllib request object and returns the (possibly modified) request; guard against attributes that may be missing.","Compare your script against the template whose path sqlmap prints in the message, and simplify until the dummy call succeeds.","Test the function locally by calling it with `_urllib.request.Request(\"http://localhost\")` in a standalone Python shell."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0a35b20e3953d341be6c7ac75ccb0b3362540c8d","analyzedAt":"2026-08-26T23:02:52.002Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}