Repository: NREL/OpenStudio (language: python)

Issue:
OS 3.6 CLI error when running OSW
Issue overview
--------------
I'm using the OS develop build (`c7160fa7b0`) and getting an error running an OSW. The error did not exist in OS 3.5.

To reproduce:
1. Check out https://github.com/NREL/OpenStudio-HPXML/tree/os360
2. Run `openstudio run -w workflow/template-run-hpxml.osw`

Error produced:
```
openstudio run -w workflow/template-run-hpxml.osw
Error executing argv: ["run", "-w", "workflow/template-run-hpxml.osw"]
Error: undefined method `each' for nil:NilClass in :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/adapters/input/local.rb:368:in `ft_options'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:205:in `initialize'
:/openstudio_cli.rb:1181:in `new'
:/openstudio_cli.rb:1181:in `execute'
:/openstudio_cli.rb:814:in `execute'
:/openstudio_cli.rb:1983:in `<main>'
eval:188:in `eval'
eval:188:in `require_embedded_absolute'
eval:173:in `block in require_embedded'
eval:167:in `each'
eval:167:in `require_embedded'
eval:126:in `require'
eval:3:in `<main>'
```
OS 3.6 CLI error when running OSW
Issue overview
--------------
I'm using the OS develop build (`c7160fa7b0`) and getting an error running an OSW. The error did not exist in OS 3.5.

To reproduce:
1. Check out https://github.com/NREL/OpenStudio-HPXML/tree/os360
2. Run `openstudio run -w workflow/template-run-hpxml.osw`

Error produced:
```
openstudio run -w workflow/template-run-hpxml.osw
Error executing argv: ["run", "-w", "workflow/template-run-hpxml.osw"]
Error: undefined method `each' for nil:NilClass in :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/adapters/input/local.rb:368:in `ft_options'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:205:in `initialize'
:/openstudio_cli.rb:1181:in `new'
:/openstudio_cli.rb:1181:in `execute'
:/openstudio_cli.rb:814:in `execute'
:/openstudio_cli.rb:1983:in `<main>'
eval:188:in `eval'
eval:188:in `require_embedded_absolute'
eval:173:in `block in require_embedded'
eval:167:in `each'
eval:167:in `require_embedded'
eval:126:in `require'
eval:3:in `<main>'
```


Discussion / hints:

Fix patch:
diff --git a/src/utilities/filetypes/ForwardTranslatorOptions.cpp b/src/utilities/filetypes/ForwardTranslatorOptions.cpp
index 49d269b091d..de37b18c281 100644
--- a/src/utilities/filetypes/ForwardTranslatorOptions.cpp
+++ b/src/utilities/filetypes/ForwardTranslatorOptions.cpp
@@ -253,11 +253,15 @@ namespace detail {
 
   std::string ForwardTranslatorOptions_Impl::string() const {
 
+    const Json::Value data = this->json();
+    if (data.isNull()) {
+      return "";
+    }
     // Write to string
     Json::StreamWriterBuilder wbuilder;
     // mimic the old StyledWriter behavior:
     wbuilder["indentation"] = "   ";
-    std::string result = Json::writeString(wbuilder, json());
+    std::string result = Json::writeString(wbuilder, data);
 
     return result;
   }


Test patch:
diff --git a/src/utilities/filetypes/test/WorkflowJSON_GTest.cpp b/src/utilities/filetypes/test/WorkflowJSON_GTest.cpp
index 3084b44411e..0e810dcba56 100644
--- a/src/utilities/filetypes/test/WorkflowJSON_GTest.cpp
+++ b/src/utilities/filetypes/test/WorkflowJSON_GTest.cpp
@@ -1170,3 +1170,9 @@ TEST(Filetypes, RunOptions_ForwardTranslate_BackwardCompatibility) {
   EXPECT_EQ("my_ruby_file.rb", workflow2->runOptions()->customOutputAdapter()->customFileName());
   EXPECT_EQ("MyOutputAdapter", workflow2->runOptions()->customOutputAdapter()->className());
 }
+
+TEST(Filetypes, RunOptions_NoFtOptions) {
+  // Test for #4815
+  const RunOptions options;
+  EXPECT_EQ("", options.forwardTranslateOptions());
+}