prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Config Support]: Docker fails to start with KeyError: 'go2rtc'
  ### Describe the problem you are having
  
  Starting an instance of frigate with a minimal config gives error `KeyError: 'go2rtc'`
  
  Config file was based on the startup walk though from DOCs https://deploy-preview-4055--frigate-docs.netlify.app/guides/getting_started
  
  Not sure if its a doc or build issue. Also tried putting in basic restream config and getting same error
  
  ### Version
  
  v0.12.0-beta4
  
  ### Frigate config file
  
  ```yaml
  mqtt:
    enabled: false
  
  cameras:
    camera_1:
      ffmpeg:
        inputs:
          - path: rtsp://10.0.20.102:554/s0
            roles:
              - detect
        hwaccel_args: -c:v h264_cuvid
      detect:
        width: 1920
        height: 1080
  ```
  
  
  ### Relevant log output
  
  ```shell
  docker-compose up
  Pulling frigate (ghcr.io/blakeblackshear/frigate:0.12.0-beta4-tensorrt)...
  0.12.0-beta4-tensorrt: Pulling from blakeblackshear/frigate
  8740c948ffd4: Pull complete
  b84a1ada9828: Pull complete
  832b257640b7: Pull complete
  60beb73d7e76: Pull complete
  8e29f3174a08: Pull complete
  4b46f368fd71: Pull complete
  b651bc39c0a3: Pull complete
  43b988f71200: Pull complete
  Digest: sha256:7010839f6794a5d21a98bc9088400fdc3c382e089539f0409e0cec1ca64473fa
  Status: Downloaded newer image for ghcr.io/blakeblackshear/frigate:0.12.0-beta4-tensorrt
  Creating frigate ... done
  Attaching to frigate
  frigate    | s6-rc: info: service s6rc-oneshot-runner: starting
  frigate    | s6-rc: info: service s6rc-oneshot-runner successfully started
  frigate    | s6-rc: info: service fix-attrs: starting
  frigate    | s6-rc: info: service fix-attrs successfully started
  frigate    | s6-rc: info: service legacy-cont-init: starting
  frigate    | cont-init: info: running /etc/cont-init.d/prepare-logs.sh
  frigate    | cont-init: info: /etc/cont-init.d/prepare-logs.sh exited 0
  frigate    | s6-rc: info: service legacy-cont-init successfully started
  frigate    | s6-rc: info: service legacy-services: starting
  frigate    | services-up: info: copying legacy longrun frigate (no readiness notification)
  frigate    | services-up: info: copying legacy longrun go2rtc (no readiness notification)
  frigate    | services-up: info: copying legacy longrun nginx (no readiness notification)
  frigate    | s6-rc: info: service legacy-services successfully started
  frigate    | Traceback (most recent call last):
  frigate    |   File "/usr/local/go2rtc/create_config.py", line 23, in <module>
  frigate    |     go2rtc_config: dict[str, any] = config["go2rtc"]
  frigate    | KeyError: 'go2rtc'
  frigate    | s6-rc: info: service legacy-services: stopping
  frigate    | s6-svwait: fatal: supervisor died
  frigate    | s6-rc: info: service legacy-services successfully stopped
  frigate    | s6-rc: info: service legacy-cont-init: stopping
  frigate    | s6-rc: info: service legacy-cont-init successfully stopped
  frigate    | s6-rc: info: service fix-attrs: stopping
  frigate    | s6-rc: info: service fix-attrs successfully stopped
  frigate    | s6-rc: info: service s6rc-oneshot-runner: stopping
  frigate    | s6-rc: info: service s6rc-oneshot-runner successfully stopped
  ```
  
  
  ### Frigate stats
  
  ```json
  N/A Frigate doesn't start
  ```
  
  
  ### Operating system
  
  Other Linux
  
  ### Install method
  
  Docker Compose
  
  ### Coral version
  
  CPU (no coral)
  
  ### Any other information that may be helpful
  
  Using a basic restream config:
  ``` yaml
  mqtt:
    enabled: false
  
    #detectors:
    #tensorrt:
    #  type: tensorrt
    #  device: 0 #This is the default, select the first GPU
  
  go2rtc:
    streams:
      test_cam: ffmpeg:rtsp://10.0.20.102:554/s0
  
  cameras:
    camera_1:
      ffmpeg:
        inputs:
          - path: rtsp://127.0.0.1:8554/test_cam?video=copy
            input_args: preset-rtsp-restream
            roles:
              - detect
        hwaccel_args: -c:v h264_cuvid
      detect:
        width: 1920
        height: 1080
  ```
  results in the same error
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `docker/rootfs/usr/local/go2rtc/create_config.py`
  Content:
  ```
  1 """Creates a go2rtc config file."""
  2 
  3 import json
  4 import os
  5 import yaml
  6 
  7 
  8 config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
  9 
  10 # Check if we can use .yaml instead of .yml
  11 config_file_yaml = config_file.replace(".yml", ".yaml")
  12 if os.path.isfile(config_file_yaml):
  13     config_file = config_file_yaml
  14 
  15 with open(config_file) as f:
  16     raw_config = f.read()
  17 
  18 if config_file.endswith((".yaml", ".yml")):
  19     config = yaml.safe_load(raw_config)
  20 elif config_file.endswith(".json"):
  21     config = json.loads(raw_config)
  22 
  23 go2rtc_config: dict[str, any] = config["go2rtc"]
  24 
  25 if not go2rtc_config.get("log", {}).get("format"):
  26     go2rtc_config["log"] = {"format": "text"}
  27 
  28 if not go2rtc_config.get("webrtc", {}).get("candidates", []):
  29     go2rtc_config["webrtc"] = {"candidates": ["stun:8555"]}
  30 
  31 print(json.dumps(go2rtc_config))
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/docker/rootfs/usr/local/go2rtc/create_config.py b/docker/rootfs/usr/local/go2rtc/create_config.py
  --- a/docker/rootfs/usr/local/go2rtc/create_config.py
  +++ b/docker/rootfs/usr/local/go2rtc/create_config.py
  @@ -5,6 +5,7 @@
   import yaml
   
   
  +BTBN_PATH = "/usr/lib/btbn-ffmpeg"
   config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
   
   # Check if we can use .yaml instead of .yml
  @@ -20,12 +21,27 @@
   elif config_file.endswith(".json"):
       config = json.loads(raw_config)
   
  -go2rtc_config: dict[str, any] = config["go2rtc"]
  +go2rtc_config: dict[str, any] = config.get("go2rtc", {})
   
  -if not go2rtc_config.get("log", {}).get("format"):
  +# we want to ensure that logs are easy to read
  +if go2rtc_config.get("log") is None:
       go2rtc_config["log"] = {"format": "text"}
  +elif go2rtc_config["log"].get("format") is None:
  +    go2rtc_config["log"]["format"] = "text"
   
  +# should set default stun server so webrtc can work
   if not go2rtc_config.get("webrtc", {}).get("candidates", []):
       go2rtc_config["webrtc"] = {"candidates": ["stun:8555"]}
   
  -print(json.dumps(go2rtc_config))
  \ No newline at end of file
  +# need to replace ffmpeg command when using ffmpeg4
  +if not os.path.exists(BTBN_PATH):
  +    if go2rtc_config.get("ffmpeg") is None:
  +        go2rtc_config["ffmpeg"] = {
  +            "rtsp": "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"
  +        }
  +    elif go2rtc_config["ffmpeg"].get("rtsp") is None:
  +        go2rtc_config["ffmpeg"][
  +            "rtsp"
  +        ] = "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"
  +
  +print(json.dumps(go2rtc_config))
  
verification_info: {"golden_diff": "diff --git a/docker/rootfs/usr/local/go2rtc/create_config.py b/docker/rootfs/usr/local/go2rtc/create_config.py\n--- a/docker/rootfs/usr/local/go2rtc/create_config.py\n+++ b/docker/rootfs/usr/local/go2rtc/create_config.py\n@@ -5,6 +5,7 @@\n import yaml\n \n \n+BTBN_PATH = \"/usr/lib/btbn-ffmpeg\"\n config_file = os.environ.get(\"CONFIG_FILE\", \"/config/config.yml\")\n \n # Check if we can use .yaml instead of .yml\n@@ -20,12 +21,27 @@\n elif config_file.endswith(\".json\"):\n     config = json.loads(raw_config)\n \n-go2rtc_config: dict[str, any] = config[\"go2rtc\"]\n+go2rtc_config: dict[str, any] = config.get(\"go2rtc\", {})\n \n-if not go2rtc_config.get(\"log\", {}).get(\"format\"):\n+# we want to ensure that logs are easy to read\n+if go2rtc_config.get(\"log\") is None:\n     go2rtc_config[\"log\"] = {\"format\": \"text\"}\n+elif go2rtc_config[\"log\"].get(\"format\") is None:\n+    go2rtc_config[\"log\"][\"format\"] = \"text\"\n \n+# should set default stun server so webrtc can work\n if not go2rtc_config.get(\"webrtc\", {}).get(\"candidates\", []):\n     go2rtc_config[\"webrtc\"] = {\"candidates\": [\"stun:8555\"]}\n \n-print(json.dumps(go2rtc_config))\n\\ No newline at end of file\n+# need to replace ffmpeg command when using ffmpeg4\n+if not os.path.exists(BTBN_PATH):\n+    if go2rtc_config.get(\"ffmpeg\") is None:\n+        go2rtc_config[\"ffmpeg\"] = {\n+            \"rtsp\": \"-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}\"\n+        }\n+    elif go2rtc_config[\"ffmpeg\"].get(\"rtsp\") is None:\n+        go2rtc_config[\"ffmpeg\"][\n+            \"rtsp\"\n+        ] = \"-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}\"\n+\n+print(json.dumps(go2rtc_config))\n", "issue": "[Config Support]: Docker fails to start with KeyError: 'go2rtc'\n### Describe the problem you are having\n\nStarting an instance of frigate with a minimal config gives error `KeyError: 'go2rtc'`\r\n\r\nConfig file was based on the startup walk though from DOCs https://deploy-preview-4055--frigate-docs.netlify.app/guides/getting_started\r\n\r\nNot sure if its a doc or build issue. Also tried putting in basic restream config and getting same error\n\n### Version\n\nv0.12.0-beta4\n\n### Frigate config file\n\n```yaml\nmqtt:\r\n  enabled: false\r\n\r\ncameras:\r\n  camera_1:\r\n    ffmpeg:\r\n      inputs:\r\n        - path: rtsp://10.0.20.102:554/s0\r\n          roles:\r\n            - detect\r\n      hwaccel_args: -c:v h264_cuvid\r\n    detect:\r\n      width: 1920\r\n      height: 1080\n```\n\n\n### Relevant log output\n\n```shell\ndocker-compose up\r\nPulling frigate (ghcr.io/blakeblackshear/frigate:0.12.0-beta4-tensorrt)...\r\n0.12.0-beta4-tensorrt: Pulling from blakeblackshear/frigate\r\n8740c948ffd4: Pull complete\r\nb84a1ada9828: Pull complete\r\n832b257640b7: Pull complete\r\n60beb73d7e76: Pull complete\r\n8e29f3174a08: Pull complete\r\n4b46f368fd71: Pull complete\r\nb651bc39c0a3: Pull complete\r\n43b988f71200: Pull complete\r\nDigest: sha256:7010839f6794a5d21a98bc9088400fdc3c382e089539f0409e0cec1ca64473fa\r\nStatus: Downloaded newer image for ghcr.io/blakeblackshear/frigate:0.12.0-beta4-tensorrt\r\nCreating frigate ... done\r\nAttaching to frigate\r\nfrigate    | s6-rc: info: service s6rc-oneshot-runner: starting\r\nfrigate    | s6-rc: info: service s6rc-oneshot-runner successfully started\r\nfrigate    | s6-rc: info: service fix-attrs: starting\r\nfrigate    | s6-rc: info: service fix-attrs successfully started\r\nfrigate    | s6-rc: info: service legacy-cont-init: starting\r\nfrigate    | cont-init: info: running /etc/cont-init.d/prepare-logs.sh\r\nfrigate    | cont-init: info: /etc/cont-init.d/prepare-logs.sh exited 0\r\nfrigate    | s6-rc: info: service legacy-cont-init successfully started\r\nfrigate    | s6-rc: info: service legacy-services: starting\r\nfrigate    | services-up: info: copying legacy longrun frigate (no readiness notification)\r\nfrigate    | services-up: info: copying legacy longrun go2rtc (no readiness notification)\r\nfrigate    | services-up: info: copying legacy longrun nginx (no readiness notification)\r\nfrigate    | s6-rc: info: service legacy-services successfully started\r\nfrigate    | Traceback (most recent call last):\r\nfrigate    |   File \"/usr/local/go2rtc/create_config.py\", line 23, in <module>\r\nfrigate    |     go2rtc_config: dict[str, any] = config[\"go2rtc\"]\r\nfrigate    | KeyError: 'go2rtc'\r\nfrigate    | s6-rc: info: service legacy-services: stopping\r\nfrigate    | s6-svwait: fatal: supervisor died\r\nfrigate    | s6-rc: info: service legacy-services successfully stopped\r\nfrigate    | s6-rc: info: service legacy-cont-init: stopping\r\nfrigate    | s6-rc: info: service legacy-cont-init successfully stopped\r\nfrigate    | s6-rc: info: service fix-attrs: stopping\r\nfrigate    | s6-rc: info: service fix-attrs successfully stopped\r\nfrigate    | s6-rc: info: service s6rc-oneshot-runner: stopping\r\nfrigate    | s6-rc: info: service s6rc-oneshot-runner successfully stopped\n```\n\n\n### Frigate stats\n\n```json\nN/A Frigate doesn't start\n```\n\n\n### Operating system\n\nOther Linux\n\n### Install method\n\nDocker Compose\n\n### Coral version\n\nCPU (no coral)\n\n### Any other information that may be helpful\n\nUsing a basic restream config:\r\n``` yaml\r\nmqtt:\r\n  enabled: false\r\n\r\n  #detectors:\r\n  #tensorrt:\r\n  #  type: tensorrt\r\n  #  device: 0 #This is the default, select the first GPU\r\n\r\ngo2rtc:\r\n  streams:\r\n    test_cam: ffmpeg:rtsp://10.0.20.102:554/s0\r\n\r\ncameras:\r\n  camera_1:\r\n    ffmpeg:\r\n      inputs:\r\n        - path: rtsp://127.0.0.1:8554/test_cam?video=copy\r\n          input_args: preset-rtsp-restream\r\n          roles:\r\n            - detect\r\n      hwaccel_args: -c:v h264_cuvid\r\n    detect:\r\n      width: 1920\r\n      height: 1080\r\n```\r\nresults in the same error\n", "before_files": [{"content": "\"\"\"Creates a go2rtc config file.\"\"\"\n\nimport json\nimport os\nimport yaml\n\n\nconfig_file = os.environ.get(\"CONFIG_FILE\", \"/config/config.yml\")\n\n# Check if we can use .yaml instead of .yml\nconfig_file_yaml = config_file.replace(\".yml\", \".yaml\")\nif os.path.isfile(config_file_yaml):\n    config_file = config_file_yaml\n\nwith open(config_file) as f:\n    raw_config = f.read()\n\nif config_file.endswith((\".yaml\", \".yml\")):\n    config = yaml.safe_load(raw_config)\nelif config_file.endswith(\".json\"):\n    config = json.loads(raw_config)\n\ngo2rtc_config: dict[str, any] = config[\"go2rtc\"]\n\nif not go2rtc_config.get(\"log\", {}).get(\"format\"):\n    go2rtc_config[\"log\"] = {\"format\": \"text\"}\n\nif not go2rtc_config.get(\"webrtc\", {}).get(\"candidates\", []):\n    go2rtc_config[\"webrtc\"] = {\"candidates\": [\"stun:8555\"]}\n\nprint(json.dumps(go2rtc_config))", "path": "docker/rootfs/usr/local/go2rtc/create_config.py"}], "after_files": [{"content": "\"\"\"Creates a go2rtc config file.\"\"\"\n\nimport json\nimport os\nimport yaml\n\n\nBTBN_PATH = \"/usr/lib/btbn-ffmpeg\"\nconfig_file = os.environ.get(\"CONFIG_FILE\", \"/config/config.yml\")\n\n# Check if we can use .yaml instead of .yml\nconfig_file_yaml = config_file.replace(\".yml\", \".yaml\")\nif os.path.isfile(config_file_yaml):\n    config_file = config_file_yaml\n\nwith open(config_file) as f:\n    raw_config = f.read()\n\nif config_file.endswith((\".yaml\", \".yml\")):\n    config = yaml.safe_load(raw_config)\nelif config_file.endswith(\".json\"):\n    config = json.loads(raw_config)\n\ngo2rtc_config: dict[str, any] = config.get(\"go2rtc\", {})\n\n# we want to ensure that logs are easy to read\nif go2rtc_config.get(\"log\") is None:\n    go2rtc_config[\"log\"] = {\"format\": \"text\"}\nelif go2rtc_config[\"log\"].get(\"format\") is None:\n    go2rtc_config[\"log\"][\"format\"] = \"text\"\n\n# should set default stun server so webrtc can work\nif not go2rtc_config.get(\"webrtc\", {}).get(\"candidates\", []):\n    go2rtc_config[\"webrtc\"] = {\"candidates\": [\"stun:8555\"]}\n\n# need to replace ffmpeg command when using ffmpeg4\nif not os.path.exists(BTBN_PATH):\n    if go2rtc_config.get(\"ffmpeg\") is None:\n        go2rtc_config[\"ffmpeg\"] = {\n            \"rtsp\": \"-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}\"\n        }\n    elif go2rtc_config[\"ffmpeg\"].get(\"rtsp\") is None:\n        go2rtc_config[\"ffmpeg\"][\n            \"rtsp\"\n        ] = \"-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}\"\n\nprint(json.dumps(go2rtc_config))\n", "path": "docker/rootfs/usr/local/go2rtc/create_config.py"}]}