{"record":{"id":"0971493147d2707e","repo":"rust-lang/rust","slug":"line","errorCode":null,"errorMessage":"line {}: {}","messagePattern":"line (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/etc/htmldocck.py","lineNumber":190,"sourceCode":"                    line,\n                    \"Deprecated command syntax, replace `// @` with `//@ `\",\n                )\n                continue\n            m = LINE_PATTERN.search(line)\n            if not m:\n                continue\n\n            cmd = m.group(\"cmd\")\n            negated = m.group(\"negated\") == \"!\"\n            args = m.group(\"args\") or \"\"\n            try:\n                args = shlex.split(args)\n            except UnicodeEncodeError:\n                args = [\n                    arg.decode(\"utf-8\") for arg in shlex.split(args.encode(\"utf-8\"))\n                ]\n            except Exception as exc:\n                raise Exception(\"line {}: {}\".format(lineno + 1, exc)) from None\n            yield Command(\n                negated=negated, cmd=cmd, args=args, lineno=lineno + 1, context=line\n            )\n\n\ndef _flatten(node, acc):\n    if node.text:\n        acc.append(node.text)\n    for e in node:\n        _flatten(e, acc)\n        if e.tail:\n            acc.append(e.tail)\n\n\ndef flatten(node):\n    acc = []\n    _flatten(node, acc)\n    return \"\".join(acc)","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/htmldocck.py#L172-L208","documentation":"Raised by get_commands() in htmldocck when shlex.split() on the args portion of a //@ directive throws an exception other than UnicodeEncodeError. The line number (1-based) and the original exception message are embedded so the offending directive in the rustdoc test template can be located. It is a template-authoring error surfaced while parsing the .rs file.","triggerScenarios":"A //@ directive line whose args string is not valid shell-lex syntax: unbalanced quotes, a stray backslash, an unclosed substitution, etc. Reached at htmldocck.py:189-190 in the generic `except Exception as exc` branch of shlex.split.","commonSituations":"Editing a rustdoc UI test and adding a directive with an unbalanced quote (e.g. `//@ has: 'foo\"`); copy-pasting a directive that contained shell metacharacters; trailing backslash in the args that confuses shlex.","solutions":["Open the .rs test file at the reported line and fix the shell syntax of the directive's arguments (balance quotes, remove stray backslashes).","Use shlex-safe quoting: wrap literal values in matching single or double quotes.","Re-run the test to confirm the parse error is gone."],"exampleFix":"// before (in the .rs file)\n//@ has: '//*[@id=\"foo\"]' \"bar\"   // line with mismatched/odd quoting\n\n// after\n//@ has: //*[@id=\"foo\"] bar","handlingStrategy":"validation","validationCode":"import shlex\n\ndef directive_args_parse_ok(args_str: str):\n    try:\n        shlex.split(args_str)\n        return True, None\n    except Exception as e:\n        return False, str(e)\n\nok, err = directive_args_parse_ok(args_string_from_template)\nif not ok:\n    raise SystemExit(f\"directive has invalid shlex syntax: {err}\")","typeGuard":"null","tryCatchPattern":"try:\n    commands = list(get_commands(template))\nexcept Exception as e:\n    if e.args and isinstance(e.args[0], str) and e.args[0].startswith(\"line \"):\n        lineno_msg = e.args[0]\n        logging.error(\"htmldocck template syntax error: %s\", lineno_msg)\n    raise","preventionTips":["Balance all quotes in //@ directive arguments.","Avoid stray backslashes in directive lines (use the line-continuation rules of concat_multi_lines instead).","Lint test templates with shlex.split in a pre-commit hook."],"tags":["htmldocck","rustdoc","parsing","shlex","test-template"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}