sqlmapproject/sqlmap · error · ValueError

the provided OpenAPI/Swagger specification is not JSON and t

Error message

the provided OpenAPI/Swagger specification is not JSON and the optional 'pyyaml' module (needed for YAML specifications) is not available

What it means

Error "the provided OpenAPI/Swagger specification is not JSON and the optional 'pyyaml' module (needed for YAML specifications) is not available" thrown in sqlmapproject/sqlmap.

Source

Thrown at lib/parse/openapi.py:37

    import yaml                                          # optional (only needed for YAML specs)
except ImportError:
    yaml = None

# Best-effort extraction of concrete request targets from an OpenAPI (v3) / Swagger (v2) document. The
# document is treated as a request generator, NOT a contract to validate: for every operation a single
# concrete request is synthesized (base URL + filled path + example query/body from the schema) and any
# operation that cannot be built is skipped with a warning, so a loose/incomplete spec degrades gracefully.

MAX_REF_DEPTH = 25

def _loadSpec(content):
    try:
        return json.loads(content)
    except ValueError:
        if yaml is None:
            errMsg = "the provided OpenAPI/Swagger specification is not JSON and the optional "
            errMsg += "'pyyaml' module (needed for YAML specifications) is not available"
            raise ValueError(errMsg)
        try:
            return yaml.safe_load(content)
        except Exception as ex:
            raise ValueError("not valid JSON nor YAML (%s)" % getSafeExString(ex))

def _resolve(spec, node, seen=None, depth=0):
    seen = seen or set()
    if isinstance(node, dict) and "$ref" in node:
        ref = node["$ref"]
        if not isinstance(ref, six.string_types):         # malformed '$ref' (non-string) -> treat as no ref
            return {}
        if ref in seen or depth > MAX_REF_DEPTH:
            return {}
        if not ref.startswith("#/"):
            logger.warning("skipping external OpenAPI $ref '%s'" % ref)
            return {}
        seen = seen | set([ref])
        current = spec

View on GitHub (pinned to 0a35b20e39)

When it happens

Trigger: Thrown at lib/parse/openapi.py:37 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/5f54a7304b3dead8. Report an issue: GitHub.