Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
21944b9
feat(metadata-db): Replace YAML config with env vars and CLI args (re…
Jul 31, 2025
bbce2fc
fix lint
Jul 31, 2025
849b6b4
fix lint
Aug 1, 2025
5806785
fix typo
Aug 1, 2025
144f74a
remove trailing space
Aug 1, 2025
eece9aa
remove trailing spaces
Aug 1, 2025
6d534b3
Apply rabbit suggestion on - docs/src/user-guide/core-unstructured/cl…
Aug 1, 2025
0cd45e3
rabbit suggestion - Update docs/src/user-guide/core-unstructured/clp.md
Aug 1, 2025
cb43f62
Remove unused `using std::exception` - Apply suggestion from @gibber9809
Aug 1, 2025
8ea2f0a
Docs - Apply suggestion from @gibber9809
Aug 1, 2025
90353c1
Remove trailing comma in arg list - Apply suggestion from @gibber9809
Aug 1, 2025
d4c17f4
refactor: Change add_command_line_options from static to instance met…
Aug 1, 2025
d3d2146
fix lint
Aug 1, 2025
a0687a5
test: Add credential reading from environment in validation tests
Aug 1, 2025
1bc0502
refactor: Introduce constants for minimum and maximum port values in …
Aug 1, 2025
690e035
lint: Remove GlobalMetadataDBConfig.cpp exception from lint configura…
Aug 1, 2025
e3a24b0
refactor: Improve error message formatting for database port range va…
Aug 1, 2025
de68007
refactor: Update minimum port value in GlobalMetadataDBConfig to 1
Aug 1, 2025
d21506b
Merge branch 'main' into db-params
Aug 1, 2025
1647e0b
Remove redundant spaces in arg list - Apply suggestion from @coderabb…
Aug 3, 2025
04923b8
Use fmt for log messages - Update components/core/src/clp/GlobalMetad…
Aug 3, 2025
aedebe1
perform mysql db type check before further parsing from env
Aug 3, 2025
5dc87d1
refactor: Skip credential reading for SQLite database type
Aug 3, 2025
968221c
rename read_credentials_from_env -> read_credentials_from_env_if_needed
Aug 3, 2025
cae4ce5
early return
Aug 3, 2025
aedca2b
reorder m_metadata_table_prefix
Aug 3, 2025
9c63298
docs: add exception detail to validate method documentation
Aug 3, 2025
47fb5d2
refactor: enhance validation for SQLite database parameters
Aug 3, 2025
54e3483
move consts to anonymous namespace; use consts for metadata db type s…
Aug 4, 2025
e39e1d7
update SQLite validation to check for default values
Aug 4, 2025
7b39750
update tests
Aug 4, 2025
2ba751d
lint
Aug 4, 2025
87cc885
Merge branch 'main' into db-params
Aug 5, 2025
1aa27fe
docs - Update docs/src/user-guide/core-unstructured/clp.md
Aug 6, 2025
dc0c899
refactor(core): make metadata DB password optional
Aug 6, 2025
a4fd245
test(core): add more unit tests for SQLite database configuration val…
Aug 6, 2025
ea9765f
test(core): add additional validation tests for GlobalMetadataDBConfig
Aug 6, 2025
06bc482
refactor(core): Change the return type of parse_args function from va…
Aug 6, 2025
eba4952
Merge branch 'main' into db-params
Aug 6, 2025
b06d71a
Docs - Update components/core/src/clp/GlobalMetadataDBConfig.cpp
Aug 7, 2025
e647fcf
Exception message - Apply suggestions from code review
Aug 7, 2025
ba0c2c5
Docs - Apply suggestions from code review
Aug 7, 2025
3745ca2
Docs - Apply suggestions from code review
Aug 7, 2025
fe3115c
style - Apply suggestions from code review
Aug 7, 2025
015f583
style - Apply suggestions from code review
Aug 7, 2025
67f2d49
style - Apply suggestions from code review
Aug 7, 2025
bec5805
Use `.at()` to access array - Apply suggestions from code review
Aug 7, 2025
aab68bf
build(core): remove CLP_NEED_YAMLCPP from set_clp_tests_dependencies
Aug 7, 2025
6279484
style(core): suppress clang-format and fix style
Aug 7, 2025
230629e
Move table_prefix variable declaration to minimize scope
Aug 7, 2025
dfde4fa
remove default values from metadata DB config descriptions
Aug 7, 2025
ae6d1e0
refactor(core): move global metadata DB config constants
Aug 7, 2025
667dce6
Move GlobalMetadataDBConfig initialization to constructor
Aug 7, 2025
57cf478
suppress clang-format; use string() instead of string_view::data() fo…
Aug 7, 2025
0f6ca85
Update GlobalMetadataDBConfig to use optional<string> for username an…
Aug 7, 2025
8df0d2f
update CLP database initialization documentation to remove default va…
Aug 7, 2025
f07d036
fix compile issue
Aug 7, 2025
3e7637c
Merge branch 'main' into db-params
Aug 7, 2025
7f52c1f
fit clang-tidy issues in test-GlobalMetadataDBConfig.cpp
Aug 8, 2025
8f6aaf9
fit clang-tidy issues in GlobalMetadataDBConfig.cpp
Aug 8, 2025
e154899
Docs - Apply suggestions from code review
Aug 11, 2025
85e00ce
rename to improve clarity of database connection functions
Aug 11, 2025
4e829ff
Change mysql-only options desc prefix - Apply suggestions from code r…
Aug 11, 2025
8c0ff24
Reformat - Apply suggestions from code review
Aug 11, 2025
ba9a0ac
Docs - Apply suggestions from code review
Aug 11, 2025
91fe771
Use init list for declartion - Apply suggestions from code review
Aug 11, 2025
179df88
Improve exception messages - Apply suggestions from code review
Aug 11, 2025
d7e6afb
Avoid inline comment & add rationale for lint suppression - Apply sug…
Aug 11, 2025
04c30ea
Use NOLINTNEXTLINE comment to suppress the concurrency-mt-unsafe warning
Aug 11, 2025
9648484
refactor: Move GlobalMetadataDBConfig default values to class scope
Aug 11, 2025
1b9d318
revert indentation change
Aug 11, 2025
c9834f3
remove redundant exception handling for metadata DB config validation
Aug 11, 2025
4971191
move global metadata DB config constants back into cpp
Aug 11, 2025
edb6810
revert indent change and suppress clang-format
Aug 11, 2025
20c61a6
add a default case to the get_metadata_db_type switch statement
Aug 11, 2025
71ed500
remove redudant namespace scope - Apply suggestions from code review
Aug 11, 2025
e3eecde
ensure MySQL credentials are provided for global metadata DB
Aug 11, 2025
b8cbe0a
docs: add exception documentation to function comments
Aug 11, 2025
7d1a273
test(core): rename test argc & argv to PascalCase
Aug 11, 2025
baf993f
lint
Aug 11, 2025
399e1bd
remove unnecessary const_cast in test-GlobalMetadataDBConfig
Aug 11, 2025
a686b54
add missing braces for MySQL case in switch statements
Aug 11, 2025
b2ad166
lint
Aug 11, 2025
e0a6ecc
Use `.value()` to get optional value instead of dereference - Apply s…
Aug 11, 2025
ea08810
Use `.value()` to get optional value instead of dereference - Apply s…
Aug 11, 2025
e14eb39
remove exception handling for metadata database config validation
Aug 11, 2025
a03cf80
test: DRY unset_env_var
Aug 11, 2025
dbe94d3
avoid inline comments
Aug 11, 2025
9cf11c3
lint
Aug 11, 2025
510bf1e
Merge branch 'main' into db-params
Aug 11, 2025
26f9a56
fix(core): improve global metadata DB config validation
Aug 11, 2025
b886c33
use constant strings for mysql and sqlite
Aug 11, 2025
2c10dbb
Use if-initializer syntax to simplify null checks for environment var…
Aug 11, 2025
69b99da
fix(core): update MySQL db type reference in global metadata DB config
Aug 11, 2025
9d5c7ab
test(core): refactor GlobalMetadataDBConfig tests
Aug 11, 2025
5156dc9
refactor: rename MySQL-related variables and options
Aug 11, 2025
f2855e4
Merge branch 'main' into db-params
Aug 11, 2025
9600944
refactor: rename MySQL-related variables as `mysql` rather than `mySql`
Aug 11, 2025
00b22b8
refactor: rename command line argument arrays with `argv`
Aug 11, 2025
b368802
rename `argV`/`argC` back to `argv` / `argc`
Aug 11, 2025
e524ed7
Extract config -> global metadata DB creation into utility function; …
Aug 13, 2025
9807fb2
IndexManager: Refactor error handling and add missing parameters to d…
Aug 13, 2025
4a2790e
test-GlobalMetadataDBConfig: Use existing constants rather than dupli…
Aug 13, 2025
ab36b4d
Refactor docs.
Aug 13, 2025
2cb4751
Fix docs error.
Aug 13, 2025
602436b
Fix clang-tidy errors I introduced.
Aug 13, 2025
e93131b
Remove unnecessary default value.
Aug 13, 2025
87c3524
Fix pre-existing clang-tidy issues.
Aug 13, 2025
7ccf42e
Fix unit tests failure.
Aug 13, 2025
f605611
Document return correctly.
Aug 13, 2025
32b06fe
Doc tweaks.
Aug 13, 2025
e2ca0b8
Apply suggestions from code review
Aug 13, 2025
e7fd723
Wrap to 100 chars.
Aug 13, 2025
0ac028e
Merge remote-tracking branch 'origin/main' into db-params
Aug 13, 2025
5267b9f
Update components/core/src/clp/clp/compression.cpp
Aug 13, 2025
a54eae2
Merge branch 'main' into db-params
Aug 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ set(SOURCE_FILES_unitTest
tests/test-ffi_KeyValuePairLogEvent.cpp
tests/test-ffi_SchemaTree.cpp
tests/test-FileDescriptorReader.cpp
tests/test-GlobalMetadataDBConfig.cpp
tests/test-Grep.cpp
tests/test-hash_utils.cpp
tests/test-ir_encoding_methods.cpp
Expand Down Expand Up @@ -774,7 +775,6 @@ if(CLP_BUILD_TESTING)
${STD_FS_LIBS}
clp::regex_utils
clp::string_utils
yaml-cpp
Comment thread
kirkrodrigues marked this conversation as resolved.
ystdlib::containers
ystdlib::error_handling
${LIBLZMA_LIBRARIES}
Expand Down
10 changes: 0 additions & 10 deletions components/core/config/metadata-db.yml

This file was deleted.

143 changes: 65 additions & 78 deletions components/core/src/clp/GlobalMetadataDBConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,110 +1,97 @@
#include "GlobalMetadataDBConfig.hpp"

#include <cstdlib>
#include <stdexcept>

#include <fmt/core.h>
#include <yaml-cpp/yaml.h>

using std::exception;
Comment thread
junhaoliao marked this conversation as resolved.
Outdated
using std::invalid_argument;
using std::string;

static exception get_yaml_missing_key_exception(string const& key_name) {
throw invalid_argument(fmt::format("Missing key '{}'", key_name));
namespace clp {
auto GlobalMetadataDBConfig::add_command_line_options(
boost::program_options::options_description& options_description
) -> void {
options_description.add_options()
Comment thread
haiqi96 marked this conversation as resolved.
Comment thread
kirkrodrigues marked this conversation as resolved.
("db-type",
boost::program_options::value<string>()->default_value("sqlite"),
"Database type [sqlite | mysql]")

ghost Aug 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we define sqlite and mysql as constants, we can then use them with fmt::format in those helper message.

That said, I feel hardcoding them isn't the end of the world since they are referring to very specific term and are very unlikely to change.

("db-host",
boost::program_options::value<string>()->default_value("127.0.0.1"),
"[db-type=mysql] Database host")
("db-port",
boost::program_options::value<int>()->default_value(cDefaultMetadataDbPort),
"[db-type=mysql] Database port")
("db-name",
boost::program_options::value<string>()->default_value("clp-db"),
"[db-type=mysql] Database name")
("db-table-prefix",
boost::program_options::value<string>()->default_value("clp_"),
"[db-type=mysql] Database table prefix");

ghost Aug 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be a bit cleaner if we make this non-static and bind these directly to member variables e.g.
"db-host", boost::program_options::value<std::string>(&m_metadata_db_host)->default_value(m_metadata_db_host),...
and then change init_from_parsed_options(...) to validate_parsed_options().

That way we can rely on the default values in the header for the default values in the command line options instead of having to repeat them here + parse the variables by name from the variables_map later.

ghost Aug 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather I guess we could just merge the bit of validation that init_from_parsed_options does into validate.

}

static exception
get_yaml_unconvertable_value_exception(string const& key_name, string const& destination_type) {
throw invalid_argument(
fmt::format("'{}' could not be converted to type '{}'", key_name, destination_type)
);
}
auto GlobalMetadataDBConfig::init_from_parsed_options(
boost::program_options::variables_map const& parsed_options
) -> void {
if (auto const db_type_string{parsed_options["db-type"].as<string>()};
"sqlite" == db_type_string)
{
m_metadata_db_type = MetadataDBType::SQLite;
} else if ("mysql" == db_type_string) {
m_metadata_db_type = MetadataDBType::MySQL;
} else {
throw invalid_argument("Unknown database type: " + db_type_string);
}

namespace clp {
void GlobalMetadataDBConfig::parse_config_file(string const& config_file_path) {
YAML::Node config = YAML::LoadFile(config_file_path);
if (m_metadata_db_type == MetadataDBType::MySQL) {
m_metadata_db_host = parsed_options["db-host"].as<string>();
m_metadata_db_port = parsed_options["db-port"].as<int>();
m_metadata_db_name = parsed_options["db-name"].as<string>();
m_metadata_table_prefix = parsed_options["db-table-prefix"].as<string>();
}
Comment on lines +114 to +118

ghost Aug 11, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Minor wording consistency in comments.

Prefer “does not” over “doesn't” for consistency.

-        // SQLite doesn't require extra parameters.
+        // SQLite does not require extra parameters.

(Apply in both locations.)

Also applies to: 131-134

🤖 Prompt for AI Agents
In components/core/src/clp/GlobalMetadataDBConfig.cpp around lines 110-114 and
131-134, update the comment wording to use “does not” instead of the contraction
“doesn't” for consistency; modify both comment instances so they read “SQLite
does not require extra parameters.” (No code logic changes needed, only replace
the contraction in those comment lines.)

}

Comment on lines +114 to 119

ghost Aug 11, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consistency nit: prefer “does not” over “doesn't” in comments.

Keep comment tone consistent throughout the file.

-        // SQLite doesn't require extra parameters.
+        // SQLite does not require extra parameters.

(Apply similarly at Line 134.)

Also applies to: 132-147

🤖 Prompt for AI Agents
components/core/src/clp/GlobalMetadataDBConfig.cpp lines 115-120 (and similarly
at line 134 and the range 132-147): comments use the contraction "doesn't" —
update these comments to use "does not" for consistent tone across the file;
scan nearby comment lines in the given ranges and replace any other contractions
to match the preferred style.

if (!config["type"]) {
throw get_yaml_missing_key_exception("type");
auto GlobalMetadataDBConfig::read_credentials_from_env() -> void {
auto const* db_username{std::getenv("CLP_DB_USER")};
if (nullptr != db_username) {
m_metadata_db_username = db_username;
}

auto db_type_string = config["type"].as<string>();
if ("sqlite" == db_type_string) {
m_metadata_db_type = MetadataDBType::SQLite;
} else if ("mysql" == db_type_string) {
m_metadata_db_type = MetadataDBType::MySQL;
auto const* db_password{std::getenv("CLP_DB_PASS")};
if (nullptr != db_password) {
m_metadata_db_password = db_password;
}
}
Comment thread
haiqi96 marked this conversation as resolved.
Outdated

if (!config["host"]) {
throw get_yaml_missing_key_exception("host");
}
try {
m_metadata_db_host = config["host"].as<string>();
} catch (YAML::BadConversion& e) {
throw get_yaml_unconvertable_value_exception("host", "string");
}
auto GlobalMetadataDBConfig::validate() const -> void {
if (m_metadata_db_type == MetadataDBType::MySQL) {

ghost Aug 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we validate that those parameters are not provided when db_type is not mysql? (unfortunately, it seems the only way to check "not provided" is to compare them with the default value.)

It can be helpful to give user an error when they specifying parameters that are not going to have effect. When we work with someone from another company, there was a time when someone provided all paramaters of a fature but missing an --enable-feature flag. The user just told us "the feature doesn't work" and It took us some cycle to finally understand the issue

if (m_metadata_db_host.empty()) {
throw invalid_argument("Database 'host' not specified or empty.");
throw invalid_argument("Database '--db-host' is empty.");
}

if (!config["port"]) {
throw get_yaml_missing_key_exception("port");
}
try {
m_metadata_db_port = config["port"].as<int>();
} catch (YAML::BadConversion& e) {
throw get_yaml_unconvertable_value_exception("port", "int");
}
if (m_metadata_db_port < 0) {
throw invalid_argument("Database 'port' cannot be negative.");
if (0 > m_metadata_db_port || 65'535 < m_metadata_db_port) {
throw invalid_argument(
"Database '--db-port' is out of range [0, 65535]: "
+ std::to_string(m_metadata_db_port)
);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

if (!config["name"]) {
throw get_yaml_missing_key_exception("name");
}
try {
m_metadata_db_name = config["name"].as<string>();
} catch (YAML::BadConversion& e) {
throw get_yaml_unconvertable_value_exception("name", "string");
}
if (m_metadata_db_name.empty()) {
throw invalid_argument("Database 'name' not specified or empty.");
throw invalid_argument("Database '--db-name' is empty.");
}

if (!config["username"]) {
throw get_yaml_missing_key_exception("username");
}
try {
m_metadata_db_username = config["username"].as<string>();
} catch (YAML::BadConversion& e) {
throw get_yaml_unconvertable_value_exception("username", "string");
if (m_metadata_table_prefix.empty()) {
throw invalid_argument("Database '--db-table_prefix' is empty.");

ghost Aug 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in error message parameter name.

The error message contains an underscore instead of a hyphen in the parameter name.

-            throw invalid_argument("Database '--db-table_prefix' is empty.");
+            throw invalid_argument("Database '--db-table-prefix' is empty.");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
throw invalid_argument("Database '--db-table_prefix' is empty.");
throw invalid_argument("Database '--db-table-prefix' is empty.");
🤖 Prompt for AI Agents
In components/core/src/clp/GlobalMetadataDBConfig.cpp at line 83, the error
message incorrectly uses an underscore in the parameter name
'--db-table_prefix'. Change the underscore to a hyphen so the message reads
'--db-table-prefix' to accurately reflect the parameter name.

}

if (m_metadata_db_username.empty()) {
throw invalid_argument("Database 'username' not specified or empty.");
throw invalid_argument("Database 'CLP_DB_USER' not specified or empty.");
}

if (!config["password"]) {
throw get_yaml_missing_key_exception("password");
}
try {
m_metadata_db_password = config["password"].as<string>();
} catch (YAML::BadConversion& e) {
throw get_yaml_unconvertable_value_exception("password", "string");
}
if (m_metadata_db_password.empty()) {
throw invalid_argument("Database 'password' not specified or empty.");
}

if (!config["table_prefix"]) {
throw get_yaml_missing_key_exception("table_prefix");
throw invalid_argument("Database 'CLP_DB_PASS' not specified or empty.");
}
try {
m_metadata_table_prefix = config["table_prefix"].as<string>();
} catch (YAML::BadConversion& e) {
throw get_yaml_unconvertable_value_exception("table_prefix", "string");
}
if (m_metadata_table_prefix.empty()) {
throw invalid_argument("Database 'table_prefix' not specified or empty.");
}
} else {
throw invalid_argument("Unknown type");
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} // namespace clp
32 changes: 30 additions & 2 deletions components/core/src/clp/GlobalMetadataDBConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <cstdint>
#include <string>

#include <boost/program_options.hpp>

namespace clp {
/**
* Class encapsulating the global metadata database's configuration details
Expand All @@ -16,11 +18,37 @@ class GlobalMetadataDBConfig {
MySQL,
};

// Static functions
/**
* Adds database-related command-line options to the given options_description.
* @param options_description
*/
static auto add_command_line_options(
boost::program_options::options_description& options_description
) -> void;

// Constructors
GlobalMetadataDBConfig() = default;

// Methods
void parse_config_file(std::string const& config_file_path);
/**
* Initializes the configuration from parsed command-line options.
* @param parsed_options
*/
auto init_from_parsed_options(boost::program_options::variables_map const& parsed_options)
-> void;

/**
* Reads database credentials from environment variables:
* - CLP_DB_USER for database username
* - CLP_DB_PASS for database password
*/
auto read_credentials_from_env() -> void;

/**
* Validates that all required parameters are provided
Comment thread
junhaoliao marked this conversation as resolved.
Outdated
*/
auto validate() const -> void;

[[nodiscard]] auto get_metadata_db_type() const -> MetadataDBType { return m_metadata_db_type; }

Expand Down Expand Up @@ -52,7 +80,7 @@ class GlobalMetadataDBConfig {

MetadataDBType m_metadata_db_type{MetadataDBType::SQLite};

std::string m_metadata_db_host{"localhost"};
std::string m_metadata_db_host{"127.0.0.1"};

ghost Aug 1, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want to change the default as 127.0.0.1 because accessing with host localhost would by default use sock connection, which isn't exposed by the package's start-clp script at least

ghost Aug 1, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can revert all related references if this change is confusing

ghost Aug 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 127.0.0.1 is reasonable, no need to revert.

int m_metadata_db_port{cDefaultMetadataDbPort};
std::string m_metadata_db_name;

ghost Aug 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you take the suggestion from my other comment we could just set all of the default values here using {}.

ghost Aug 1, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted the default values as constants, and in add_command_lines_options i specified the arguments' default values as those extracted constants, just in case someone calls add_command_lines_options() multiple times. (i feel it's unlikely someone would call that method multiple times but since we didn't really say that's prohibited in the docs, we should try to handle such call sequences)


Expand Down
1 change: 0 additions & 1 deletion components/core/src/clp/clg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ if(CLP_BUILD_EXECUTABLES)
${sqlite_LIBRARY_DEPENDENCIES}
${STD_FS_LIBS}
clp::string_utils
yaml-cpp
ystdlib::containers
ystdlib::error_handling
ZStd::ZStd
Expand Down
39 changes: 16 additions & 23 deletions components/core/src/clp/clg/CommandLineArguments.cpp
Comment thread
junhaoliao marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,14 @@ CommandLineArguments::parse_arguments(int argc, char const* argv[]) {
config_file_path += '/';
}
config_file_path += cDefaultConfigFilename;
string global_metadata_db_config_file_path;
options_general.add_options()
("help,h", "Print help")
("version,V", "Print version")
(
"config-file",
po::value<string>(&config_file_path)->value_name("FILE")
->default_value(config_file_path),
"Use configuration options from FILE"
)(
"db-config-file",
po::value<string>(&global_metadata_db_config_file_path)->value_name("FILE")
->default_value(global_metadata_db_config_file_path),
"Global metadata DB YAML config"
);
options_general.add_options()("help,h", "Print help")("version,V", "Print version")(
"config-file",
po::value<string>(&config_file_path)
->value_name("FILE")
->default_value(config_file_path),
"Use configuration options from FILE"
);

ghost Aug 6, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn off clang-format and reformat as before.

GlobalMetadataDBConfig::add_command_line_options(options_general);

// Define input options
po::options_description options_input("Input Options");
Expand Down Expand Up @@ -195,14 +188,14 @@ CommandLineArguments::parse_arguments(int argc, char const* argv[]) {
return ParsingResult::InfoCommand;
}

// Parse and validate global metadata DB config
if (false == global_metadata_db_config_file_path.empty()) {
try {
m_metadata_db_config.parse_config_file(global_metadata_db_config_file_path);
} catch (std::exception& e) {
SPDLOG_ERROR("Failed to validate metadata database config - {}", e.what());
return ParsingResult::Failure;
}
// Initialize and validate global metadata DB config
try {
m_metadata_db_config.init_from_parsed_options(parsed_command_line_options);
m_metadata_db_config.read_credentials_from_env();

ghost Aug 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
if I only read this piece of code, it gives me the feeling that m_metadata_db_config will always read credentials, which is not true. I think there are few alternative:

  1. rename read_credentials_from_env to something like read_credentials_from_env_if_needed
  2. explictily check the m_metadata_db_config's type and put read_credentials_from_env under a if-clause.

ghost Aug 4, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now addressed as responded at #1148 (comment)

m_metadata_db_config.validate();
} catch (std::exception& e) {
SPDLOG_ERROR("Failed to validate metadata database config - {}", e.what());
return ParsingResult::Failure;
}

// Validate archive path was specified
Expand Down
1 change: 0 additions & 1 deletion components/core/src/clp/clp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ if(CLP_BUILD_EXECUTABLES)
nlohmann_json::nlohmann_json
${STD_FS_LIBS}
clp::string_utils
yaml-cpp
ystdlib::containers
ystdlib::error_handling
ZStd::ZStd
Expand Down
42 changes: 16 additions & 26 deletions components/core/src/clp/clp/CommandLineArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,14 @@ CommandLineArguments::parse_arguments(int argc, char const* argv[]) {
config_file_path += '/';
}
config_file_path += cDefaultConfigFilename;
string global_metadata_db_config_file_path;
options_general.add_options()
("help,h", "Print help")
("version,V", "Print version")
(
"config-file",
po::value<string>(&config_file_path)
->value_name("FILE")
->default_value(config_file_path),
"Use configuration options from FILE"
)
(
"db-config-file",
po::value<string>(&global_metadata_db_config_file_path)
->value_name("FILE")
->default_value(global_metadata_db_config_file_path),
"Global metadata DB YAML config"
);
options_general.add_options()("help,h", "Print help")("version,V", "Print version")(
"config-file",
po::value<string>(&config_file_path)
->value_name("FILE")
->default_value(config_file_path),
"Use configuration options from FILE"
);

ghost Aug 10, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn off clang-format and reformat as before.

GlobalMetadataDBConfig::add_command_line_options(options_general);

// Define functional options
po::options_description options_functional("Input Options");
Expand Down Expand Up @@ -121,14 +111,14 @@ CommandLineArguments::parse_arguments(int argc, char const* argv[]) {
return ParsingResult::InfoCommand;
}

// Parse and validate global metadata DB config
if (false == global_metadata_db_config_file_path.empty()) {
try {
m_metadata_db_config.parse_config_file(global_metadata_db_config_file_path);
} catch (std::exception& e) {
SPDLOG_ERROR("Failed to validate metadata database config - {}", e.what());
return ParsingResult::Failure;
}
// Initialize and validate global metadata DB config
try {
m_metadata_db_config.init_from_parsed_options(parsed_command_line_options);
m_metadata_db_config.read_credentials_from_env();
m_metadata_db_config.validate();
} catch (std::exception& e) {
SPDLOG_ERROR("Failed to validate metadata database config - {}", e.what());
return ParsingResult::Failure;
}

// Validate command
Expand Down
1 change: 0 additions & 1 deletion components/core/src/clp_s/indexer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ if(CLP_BUILD_EXECUTABLES)
OpenSSL::Crypto
simdjson::simdjson
spdlog::spdlog
yaml-cpp
ystdlib::containers
ZStd::ZStd
)
Expand Down
Loading