sqlmapproject/sqlmap · error · SqlmapGenericException

make sure that there is an empty file '__init__.py' inside…

Error message

make sure that there is an empty file '__init__.py' inside of preprocess scripts directory '%s'

What it means

While loading scripts given via --preprocess, _setPreprocessFunctions splits each script into directory and filename, then requires the directory to be a Python package by checking for an empty __init__.py. The check is a package-layout validation: without __init__.py the directory cannot be reliably imported via sys.path insertion, so sqlmap refuses to import the preprocess module and raises SqlmapGenericException naming the offending directory.

Solutions

  1. Create an empty __init__.py file in the directory containing the preprocess script (e.g. `touch /path/to/scripts/__init__.py`).
  2. Verify the --preprocess value points to the correct directory and that the file was not deleted or renamed.
  3. Ensure the process user has write permission to the scripts directory so __init__.py can be created there.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/core/option.py:1006 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/28da2aefd15c2d1e. Report an issue: GitHub.

Appendix: source

Thrown at lib/core/option.py:1006

                    raise SqlmapFilePathException(errMsg)

                elif not script.endswith(".py"):
                    errMsg = "preprocess script '%s' should have an extension '.py'" % script
                    raise SqlmapSyntaxException(errMsg)
            except UnicodeDecodeError:
                errMsg = "invalid character provided in option '--preprocess'"
                raise SqlmapSyntaxException(errMsg)

            dirname, filename = os.path.split(script)
            dirname = os.path.abspath(dirname)

            infoMsg = "loading preprocess module '%s'" % filename[:-3]
            logger.info(infoMsg)

            if not os.path.exists(os.path.join(dirname, "__init__.py")):
                errMsg = "make sure that there is an empty file '__init__.py' "
                errMsg += "inside of preprocess scripts directory '%s'" % dirname
                raise SqlmapGenericException(errMsg)

            if dirname not in sys.path:
                sys.path.insert(0, dirname)

            try:
                getattr(importlib, "invalidate_caches", lambda: None)()  # Note: py3.3+ only; a script just written into an already-scanned dir is invisible to a cached FileFinder (Windows coarse mtime)
                module = __import__(safeFilepathEncode(filename[:-3]))
            except Exception as ex:
                raise SqlmapSyntaxException("cannot import preprocess module '%s' (%s)" % (getUnicode(filename[:-3]), getSafeExString(ex)))

            for name, function in inspect.getmembers(module, inspect.isfunction):
                try:
                    if name == "preprocess" and inspect.getargspec(function).args and all(_ in inspect.getargspec(function).args for _ in ("req",)):
                        found = True

                        kb.preprocessFunctions.append(function)
                        function.__name__ = module.__name__

View on GitHub (pinned to 0a35b20e39)