Skip to content

Commit f802e36

Browse files
author
Józef Daniecki
committed
Validate schema_dir is non-empty for API scene source
Add early validation in create_scene_loader to throw a clear error when schema_dir is empty and scenes.source='api', instead of failing later with a confusing 'Failed to open scene schema' message. Add corresponding unit test FactoryRequiresSchemaDir.
1 parent e9d458d commit f802e36

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

tracker/src/scene_loader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ create_scene_loader(const ScenesConfig& config, const std::filesystem::path& con
8484
if (!manager_config.has_value()) {
8585
throw std::runtime_error("Manager config is required when scenes.source='api'");
8686
}
87+
if (schema_dir.empty()) {
88+
throw std::runtime_error(
89+
"Missing required config: scenes.schema_dir (required when "
90+
"scenes.source='api')");
91+
}
8792
return create_api_scene_loader(*manager_config, schema_dir);
8893
}
8994
}

tracker/test/unit/api_scene_loader_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ TEST(ApiSceneLoaderTest, FactoryRequiresManagerConfig) {
6363
EXPECT_THROW(create_scene_loader(config, "/tmp", std::nullopt, "/tmp"), std::runtime_error);
6464
}
6565

66+
TEST(ApiSceneLoaderTest, FactoryRequiresSchemaDir) {
67+
ScenesConfig config;
68+
config.source = SceneSource::Api;
69+
70+
ManagerConfig mgr;
71+
mgr.url = "https://localhost:443";
72+
mgr.auth_path = "/tmp/nonexistent-auth.json";
73+
74+
// Empty schema_dir -> should throw with clear message
75+
EXPECT_THROW(create_scene_loader(config, "/tmp", mgr, ""), std::runtime_error);
76+
}
77+
6678
TEST(ApiSceneLoaderTest, FactoryCreatesLoaderWithManagerConfig) {
6779
ScenesConfig config;
6880
config.source = SceneSource::Api;

0 commit comments

Comments
 (0)