{"record":{"id":"3793689e2bdb1666","repo":"SeleniumHQ/selenium","slug":"expected-exactly-one-webref-cddl-extension-use-rep","errorCode":null,"errorMessage":"Expected exactly one webref_cddl_extension use_repo block, found {count}","messagePattern":"Expected exactly one webref_cddl_extension use_repo block, found (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/update_cddl.py","lineNumber":197,"sourceCode":"        f'_BIDI_SPEC_HTML_SHA256 = \"{bidi_sha256}\"',\n        \"_BIDI_SPEC_HTML_SHA256 assignment\",\n    )\n\n    BZL_FILE.write_text(content)\n\n\ndef update_module(repo_names):\n    content = MODULE_FILE.read_text()\n    repo_list = \"\\n\".join(f'    \"{name}\",' for name in sorted(repo_names))\n    new_block = f\"use_repo(\\n    webref_cddl_extension,\\n{repo_list}\\n)\"\n    content, count = re.subn(\n        r\"use_repo\\(\\n    webref_cddl_extension,\\n.*?\\n\\)\",\n        new_block,\n        content,\n        flags=re.S,\n    )\n    if count != 1:\n        raise RuntimeError(f\"Expected exactly one webref_cddl_extension use_repo block, found {count}\")\n    MODULE_FILE.write_text(content)\n\n\ndef main():\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--commit\", help=\"pin this exact webref commit instead of the branch tip\")\n    parser.add_argument(\n        \"--branch\",\n        default=\"main\",\n        help=\"webref branch to resolve when --commit is omitted (default: main)\",\n    )\n    args = parser.parse_args()\n\n    commit = args.commit or resolve_commit(args.branch)\n    print(f\"Pinning {REPO}@{commit}\")\n\n    before = existing_repo_names(BZL_FILE.read_text())\n","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/scripts/update_cddl.py#L179-L215","documentation":"Raised by update_module() in scripts/update_cddl.py when the regex substitution for the use_repo(webref_cddl_extension, ...) block in MODULE.bazel does not match exactly once. The regex searches for 'use_repo(\\n    webref_cddl_extension,\\n.*?\\n)'. If count != 1, the MODULE.bazel file either lacks this block entirely or has been modified to have zero or multiple matches.","triggerScenarios":"Running update_cddl.py when MODULE.bazel has been edited to remove, reformat, or duplicate the use_repo(webref_cddl_extension, ...) block. The regex is strict about the formatting (must start with 'use_repo(\\n    webref_cddl_extension,'), so any whitespace or formatting change breaks the match.","commonSituations":"Manual reformatting of MODULE.bazel (e.g., by a Bazel formatter or editor); the use_repo block was renamed or removed during a Bazel module migration; merge conflicts altered the block formatting; someone changed the indentation or added comments inside the block that break the regex.","solutions":["Inspect MODULE.bazel to verify the use_repo(webref_cddl_extension, ...) block exists with the expected formatting.","Restore MODULE.bazel from git (git checkout MODULE.bazel) if it was manually corrupted.","If the block was intentionally reformatted, update the regex pattern in update_module() to match the new format.","Ensure there is exactly one such block."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"import re\n\ncontent = open('MODULE.bazel').read()\nmatches = re.findall(r'use_repo\\(\\n    webref_cddl_extension,\\n.*?\\n\\)', content, flags=re.S)\nif len(matches) != 1:\n    print(f'WARNING: found {len(matches)} use_repo(webref_cddl_extension) blocks, expected 1')","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Do not reformat the use_repo(webref_cddl_extension, ...) block in MODULE.bazel — keep the exact indentation the script expects.","Run update_cddl.py regularly to keep MODULE.bazel in sync.","If reformating is necessary, update the regex in update_module() to match."],"tags":["selenium","build-script","update-cddl","regex","bazel","module-bazel","ci"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}