ansible/ansible · error · ValueError

No start of json char found

Error message

No start of json char found

What it means

Error "No start of json char found" thrown in ansible/ansible.

Source

Thrown at lib/ansible/modules/async_wrapper.py:94

def _filter_non_json_lines(data):
    """
    Used to filter unrelated output around module JSON output, like messages from
    tcagetattr, or where dropbear spews MOTD on every single command (which is nuts).

    Filters leading lines before first line-starting occurrence of '{', and filter all
    trailing lines after matching close character (working from the bottom of output).
    """
    warnings = []

    # Filter initial junk
    lines = data.splitlines()

    for start, line in enumerate(lines):
        line = line.strip()
        if line.startswith(u'{'):
            break
    else:
        raise ValueError('No start of json char found')

    # Filter trailing junk
    lines = lines[start:]

    for reverse_end_offset, line in enumerate(reversed(lines)):
        if line.strip().endswith(u'}'):
            break
    else:
        raise ValueError('No end of json char found')

    if reverse_end_offset > 0:
        # Trailing junk is uncommon and can point to things the user might
        # want to change.  So print a warning if we find any
        trailing_junk = lines[len(lines) - reverse_end_offset:]
        for line in trailing_junk:
            if line.strip():
                warnings.append('Module invocation had junk after the JSON data: %s' % '\n'.join(trailing_junk))
                break

View on GitHub (pinned to 9cf16a4aca)

Solutions

  1. Re-run the async task; the async job file output was malformed.
  2. Check for output truncation or encoding issues in async results.

When it happens

Trigger: Thrown at lib/ansible/modules/async_wrapper.py:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ansible/ansible@9cf16a4aca (2026-08-15). Data as JSON: /api/errors/8800c27eccb76743. Report an issue: GitHub.