From 5848bdd9905413b9c548321108e892273936076f Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 25 Jul 2020 18:50:54 +0300
Subject: [PATCH] Another SDK fix attempt

---
 components/common/cpp/src/configurable.cpp  | 4 ++++
 components/common/cpp/src/configuration.cpp | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/components/common/cpp/src/configurable.cpp b/components/common/cpp/src/configurable.cpp
index fd8db20e3..1f377fc51 100644
--- a/components/common/cpp/src/configurable.cpp
+++ b/components/common/cpp/src/configurable.cpp
@@ -22,6 +22,10 @@ Configurable::Configurable(nlohmann::json &config) : config_(&config) {
 		LOG(FATAL) << "Configurable json is not an object: " << config;
 	}
 
+	/*if (!config.contains("$id")) {
+		config["$id"] = "ftl://utu.fi";
+	}*/
+
 	ftl::config::registerConfigurable(this);
 }
 
diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp
index 522ce44bd..20173db52 100644
--- a/components/common/cpp/src/configuration.cpp
+++ b/components/common/cpp/src/configuration.cpp
@@ -276,6 +276,8 @@ static void _indexConfig(json_t &cfg) {
 }
 
 ftl::Configurable *ftl::config::find(const std::string &uri) {
+	if (uri.size() == 0) return nullptr;
+
 	std::string actual_uri = uri;
 	if (uri[0] == '/') {
 		if (uri.size() == 1) {
@@ -876,6 +878,10 @@ Configurable *ftl::config::configure(int argc, char **argv, const std::string &r
 	string root_str = (options.find("root") != options.end()) ? nlohmann::json::parse(options["root"]).get<string>() : root;
 	cfg_root_str = root_str;
 
+	if (!config.contains("$id")) {
+		config["$id"] = "ftl://utu.fi";
+	}
+
 	if (options.find("id") != options.end()) config["$id"] = nlohmann::json::parse(options["id"]).get<string>();
 	_indexConfig(config);
 
-- 
GitLab