{"record":{"id":"0d2aaa789770ec92","repo":"bazelbuild/bazel","slug":"could-not-get-config-stderr","errorCode":null,"errorMessage":"Could not get config: {stderr}","messagePattern":"Could not get config: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/ctexplain/bazel_api.py","lineNumber":114,"sourceCode":"\n    Args:\n      config_hash: A config hash as reported by \"bazel cquery\".\n\n    Returns:\n      The matching configuration or None if no match is found.\n\n    Raises:\n      ValueError: On any parsing problems.\n    \"\"\"\n    if config_hash == \"HOST\":\n      return HostConfiguration()\n    elif config_hash == \"null\":\n      return NullConfiguration()\n\n    base_args = [\"config\", \"--output=json\"]\n    (returncode, stdout, stderr) = self.run_bazel(base_args + [config_hash])\n    if returncode != 0:\n      raise ValueError(\"Could not get config: \" + stderr)\n    config_json = json.loads(os.linesep.join(stdout))\n    fragments = frozendict({\n        _base_name(entry[\"name\"]):\n        tuple(_base_name(clazz) for clazz in entry[\"fragmentOptions\"])\n        for entry in config_json[\"fragments\"]\n    })\n    options = frozendict({\n        _base_name(entry[\"name\"]): frozendict(entry[\"options\"])\n        for entry in config_json[\"fragmentOptions\"]\n    })\n    return Configuration(fragments, options)\n\n\n# TODO(gregce): have cquery --output=jsonproto support --show_config_fragments\n# so we can replace all this regex parsing with JSON reads.\ndef _parse_cquery_result_line(line: str) -> ConfiguredTarget:\n  \"\"\"Converts a cquery output line to a ConfiguredTarget.\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/tools/ctexplain/bazel_api.py#L96-L132","documentation":"Thrown by tools/ctexplain's bazel_api.get_config() when 'bazel config --output=json <hash>' exits non-zero. ctexplain resolves each configuration hash from cquery output into a full Configuration via this call; failure to fetch the config aborts with the raw bazel stderr attached.","triggerScenarios":"Passing a config hash that the current bazel server does not know (from a stale cquery dump or a different output base), the bazel server being shut down mid-run, or bazel itself erroring (e.g. workspace problems) during 'bazel config'.","commonSituations":"Comparing cquery output captured before a 'bazel clean' or server restart; running ctexplain in a workspace where bazel needs a restart (version change); config hash from another invocation directory.","solutions":["Run 'bazel config <hash>' manually with the same output base to see the underlying bazel error shown in stderr.","Regenerate the cquery data you are diffing in the same workspace state so hashes exist in the current server.","Restart/shut down the bazel server ('bazel shutdown') if a version or workspace change invalidated it, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"rc, out, err = run_bazel(['config', '--output=json', config_hash])\nif rc != 0:\n    raise ValueError('config %s unknown to server: %s' % (config_hash, err))","typeGuard":null,"tryCatchPattern":"try:\n    config = bazel.get_config(ct.config_hash)\nexcept ValueError as e:\n    # 'Could not get config: ...' — regenerate cquery data in this workspace\n    raise","preventionTips":["Generate and consume cquery dumps within one bazel server lifetime.","Pre-check unknown hashes with 'bazel config <hash>' before running ctexplain on old data."],"tags":["ctexplain","cquery","bazel","configuration"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}