Repository: googleapis/synthtool

Issue:
Owlbot post-processor failing on repo-automation-bots
```
Traceback (most recent call last):
  File "/workspace/repo-automation-bots/owlbot.py", line 16, in <module>
    node.owlbot_main(templates_excludes=[
  File "/synthtool/synthtool/languages/node.py", line 343, in owlbot_main
    library_version = template_metadata()["version"]
KeyError: 'version'
```

Discussion:
gcf-merge-on-green[bot]: Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

Patch:
diff --git a/synthtool/languages/node.py b/synthtool/languages/node.py
index ee27ae8..3af0f42 100644
--- a/synthtool/languages/node.py
+++ b/synthtool/languages/node.py
@@ -340,8 +340,9 @@ def owlbot_main(
         templates = common_templates.node_library(source_location="build/src")
         s_copy([templates], excludes=templates_excludes)
 
-    library_version = template_metadata()["version"]
-    common.update_library_version(library_version, _GENERATED_SAMPLES_DIRECTORY)
+    library_version = template_metadata().get("version")
+    if library_version:
+        common.update_library_version(library_version, _GENERATED_SAMPLES_DIRECTORY)
 
 
 if __name__ == "__main__":


Test patch:
diff --git a/tests/fixtures/node_templates/no_version/.repo-metadata.json b/tests/fixtures/node_templates/no_version/.repo-metadata.json
new file mode 100644
index 0000000..094082c
--- /dev/null
+++ b/tests/fixtures/node_templates/no_version/.repo-metadata.json
@@ -0,0 +1,11 @@
+{
+  "name": "repo-automation-bots",
+  "name_pretty": "Repo Automation Bots",
+  "release_level": "stable",
+  "language": "nodejs",
+  "repo": "googleapis/repo-automation-bots",
+  "distribution_name": "repo-automation-bots",
+  "codeowner_team": "@googleapis/github-automation",
+  "client_documentation": "https://cloud.google.com/nodejs/docs/reference/repo-automation-bots/latest",
+  "library_type": "OTHER"
+}
diff --git a/tests/fixtures/node_templates/no_version/package.json b/tests/fixtures/node_templates/no_version/package.json
new file mode 100644
index 0000000..1ff2523
--- /dev/null
+++ b/tests/fixtures/node_templates/no_version/package.json
@@ -0,0 +1,22 @@
+{
+  "name": "repo-automation-bots",
+  "private": true,
+  "license": "Apache-2.0",
+  "repository": "googleapis/repo-automation-bots",
+  "engines": {
+    "node": ">=12.0.0"
+  },
+  "scripts": {
+    "run": "./scripts/scripts.js",
+    "fix": "npm run run -- npm run fix",
+    "test": "c8 npm run run -- npm test",
+    "proxy": "smee",
+    "generate-bot": "node ./packages/generate-bot/run.js"
+  },
+  "devDependencies": {
+    "c8": "^7.1.0",
+    "gaxios": "^5.0.0",
+    "smee-client": "^1.1.0",
+    "@google-cloud/mono-repo-publish": "^1.0.0"
+  }
+}
diff --git a/tests/test_node.py b/tests/test_node.py
index 3838764..481327e 100644
--- a/tests/test_node.py
+++ b/tests/test_node.py
@@ -276,3 +276,9 @@ def test_owlbot_main_with_staging_patch_staging(hermetic_mock, nodejs_dlp):
     assert "import * as v2" in staging_text
     assert "export * as v2" not in staging_text
     assert "export * as v2" in text
+
+
+def test_owlbot_main_without_version():
+    with util.copied_fixtures_dir(FIXTURES / "node_templates" / "no_version"):
+        # just confirm it doesn't throw an exception.
+        node.owlbot_main(TEMPLATES)