feat(configs): list configuration environment variables - #4350
ParthibanRajasekaran wants to merge 43 commits into
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
1. Documentation: Expand --list-config-env-vars help text to document template syntax (<N> for vector indices, <KEY> for connector keys, <FIELD> for plugin config fields) and behavior (early exit before any startup). Enables users to understand templates without reading code. 2. Consistency: Unify print_config_env_vars() across all three binaries to use static &'static str templates consistently, reducing allocations and code complexity in connectors binary. 3. Test coverage: Add comprehensive subprocess tests for edge cases: - Vector index template expansion (<N> and nested <N>_..._<N>) - Connector SINK/SOURCE and PLUGIN_CONFIG template formatting - Deduplication correctness across multiple runs - Early exit with invalid environment values (no validation before exit) These improvements ensure implementation matches issue apache#4322 scope: "Document the flag and placeholders in --help and configuration docs" "Subprocess tests verify... index bounds and sink/source templates"
Ensures compliance with CONTRIBUTING.md code quality requirements.
|
/ready |
|
/skill team-review-slim |
There was a problem hiding this comment.
Summary: The templates mirror the compiled env mappings and each listing covers the names its binary reads. The findings are duplication, documentation placement, a missing consistency test, an unused template field, and a panic when the listing's stdout closes early.
The head moved while this review ran (b98113ace reviewed, 5d2981aac now), so the findings stay in this body instead of on lines.
Counts: critical 0, warning 0, nit 5, simplification 5
Findings without an anchor on a changed line:
core/server/src/main.rs:116simplification:print_config_env_varscopies 7 of the 14 names inSERVER_PROCESS_ENV_VARS, so the listing omits the other 7 and drifts on the next edit. Chain the constant instead of the literals.core/connectors/runtime/src/main.rs:160simplification: The listing hardcodes theIGGY_CONNECTORS_{TYPE}_{KEY}_prefix that the runtime builds inConnectorEnvProvider::with_connector_base_config. Reuse one prefix builder here, so the listing cannot drift from the names the runtime reads.core/connectors/runtime/src/main.rs:168simplification: The function builds three collections to produce one list:names,sink_source_templatesandall_names. Collect into a singleVec<String>and chain the sink and source templates into it.core/configs/src/configs_impl/env_mapping.rs:41simplification:max_elementsrecords each placeholder's limit, but no production code reads it: the derive only copies it and the listing prints names alone. Print the limit beside each name, or drop the field and the limits chain.core/integration/tests/config_env_listing.rs:127simplification:config_env_listing_deduplicates_outputreruns all three binaries to prove deduplication, butconfig_env_listing_exits_before_startup_for_each_binaryalready asserts strictly increasing output for the same binaries. Delete the test.core/configs_derive/src/config_env.rs:398nit: The template walk mirrors the mapping walk, and no test ties the two together, so one edit can desync the listing. Add a test that strips index digits from everyenv_mappings()name and looks it up inenv_templates().core/server/src/args.rs:95nit: The help lists<KEY>and<FIELD>, butiggy-serverprints neither. Onlyiggy-connectorsemits those placeholders and its help explains none, so move the legend there.core/server/src/args.rs:94nit:--helpprints this comment as written, so the backticks around<N>,<KEY>and<FIELD>reach the operator's terminal. Drop the backticks.core/integration/tests/config_env_listing.rs:154nit:TcpConfighas no port field, soIGGY_TCP_PORTnames no setting and the comment about an invalid port value is wrong. Drop the line, as the invalidIGGY_HTTP_ADDRESSalready covers the case.core/server/src/main.rs:127nit: If the reader closes stdout early, thisprintln!loop panics on the failed write and exits 101, as--list-config-env-vars | headdoes. Write withwriteln!and stop on the first write error.
This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.
…/ParthibanRajasekaran/iggy into codex/issue-4322-config-env-vars
|
please use |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4350 +/- ##
=============================================
- Coverage 87.96% 74.63% -13.33%
+ Complexity 1579 1578 -1
=============================================
Files 1290 1289 -1
Lines 230145 209753 -20392
Branches 193480 173089 -20391
=============================================
- Hits 202440 156557 -45883
- Misses 22980 48499 +25519
+ Partials 4725 4697 -28
🚀 New features to boost your workflow:
|
…/ParthibanRajasekaran/iggy into codex/issue-4322-config-env-vars
|
@hubcio PR title updated as per suggestion and the PR is now ready for review |
…_vars Use writeln! with error handling instead of println! to ensure the print_config_env_vars function handles early pipe closure correctly, improving test coverage to 100%. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…/ParthibanRajasekaran/iggy into codex/issue-4322-config-env-vars
|
/ready |
hubcio
left a comment
There was a problem hiding this comment.
the head does not compile at e9feb351a. please build and run prek run locally before the next push.
nit: core/server/README.md:30 says --replica-id is the only command line argument, but the server already had three flags and this PR adds a fourth. list the flags, or point to iggy-server --help.
…/ParthibanRajasekaran/iggy into codex/issue-4322-config-env-vars
|
/ready |
|
why arent you using precommit hooks? please dont push broken code to PR. see CONTRIBUTING.md. besides precommit hooks you are required to run tests locally + they have to be passing. |
Applied consistent code formatting across all modified files to pass precommit hook checks.
hubcio
left a comment
There was a problem hiding this comment.
the tests don't build at cf9b0bf6: cargo check -p configs --tests fails with E0432, cargo fmt --all -- --check fails in 9 files, and clippy fails in the connectors main.rs. please run fmt, clippy with -D warnings and prek run locally before the next push.
…/ParthibanRajasekaran/iggy into codex/issue-4322-config-env-vars
|
/ready |
hubcio
left a comment
There was a problem hiding this comment.
one warning left, the rest are nits and simplifications.
outside the diff:
- nit: the connectors and MCP READMEs (
core/connectors/runtime/README.md:48,core/ai/mcp/README.md:57) don't mention--list-config-env-vars. add a line each, with<KEY>,<N>and<FIELD>only in the connectors one.
| "{name} is read by a sibling binary before its config loads, so the scan must skip it" | ||
| ); | ||
| } | ||
| let runtime_env_vars = super::super::CONNECTORS_RUNTIME_ENV_VARS |
There was a problem hiding this comment.
warning: this test now takes its names from the same lists is_runtime_env_var reads, so it still passes if a path name drops out, and a debug build then panics when that var is set. pin the four literal names again.
| @@ -625,19 +620,13 @@ mod tests { | |||
| #[test] | |||
There was a problem hiding this comment.
nit: the doc comment above still says the list check holds in both build profiles, but the assert! loop is gone and a release build now asserts nothing. restore the check or drop that sentence.
| /// call, one error policy. A closed writer (e.g. `iggy-server --list-config-env-vars | head -1`) | ||
| /// is expected, not a failure: on `BrokenPipe` this stops writing and returns `Ok(())`. Any | ||
| /// other I/O error is real and is propagated so the caller exits non-zero. | ||
| pub fn print_env_var_names<I, S, W>(names: I, writer: &mut W) -> std::io::Result<()> |
There was a problem hiding this comment.
nit: the writer param is in now, but nothing drives it - add two unit tests with writers that fail with BrokenPipe (expect Ok) and StorageFull (expect Err).
| pub const MCP_CONFIG_PATH_ENV: &str = "IGGY_MCP_CONFIG_PATH"; | ||
| pub const MCP_ENV_PATH_ENV: &str = "IGGY_MCP_ENV_PATH"; | ||
| pub const MCP_RUNTIME_ENV_VARS: &[&str] = | ||
| &["IGGY_DISPLAY_CONFIG", MCP_CONFIG_PATH_ENV, MCP_ENV_PATH_ENV]; |
There was a problem hiding this comment.
nit: "IGGY_DISPLAY_CONFIG" is still a literal here and at line 58, but file_provider.rs:29 already has DISPLAY_CONFIG_ENV. make it pub(crate) and use it in both lists.
|
|
||
| impl EnvVarTemplate { | ||
| /// Expands this template into every concrete mapping it represents. | ||
| pub fn expand(&self) -> Vec<EnvVarMapping> { |
There was a problem hiding this comment.
nit: expand has one caller (expand_env_templates) and leaks two strings per mapping on every call - make it private and note the leak on expand_env_templates.
| .arg("--list-config-env-vars") | ||
| .timeout(LIST_ENV_VARS_TIMEOUT); | ||
|
|
||
| for (key, value) in env { |
There was a problem hiding this comment.
simplification: assert_cmd's Command has envs and args, so these two loops can be .envs(env).args(extra_args) on the builder.
| assert!( | ||
| names | ||
| .iter() | ||
| .any(|name| name.contains("IGGY_CLUSTER_NODES_<N>_")), |
There was a problem hiding this comment.
simplification: the checks at lines 167, 192 and 198 are implied by the longer ones at 175, 216 and 220 - drop them.
| let ty = &info.element_type; | ||
| let segment = &info.field_env_segment; | ||
| let field_name = &info.field_name; | ||
| if info.is_vec { |
There was a problem hiding this comment.
simplification: the Vec and plain branches emit the same loop and differ only in the <N> segment and the limits - pick those at macro time and emit one loop.
| let env_mappings_impl = if nested_fields.is_empty() && !has_prefix { | ||
| // Simple case: no nested fields, no prefix transformation needed | ||
| }); | ||
| let template_prefix_application = if has_prefix { |
There was a problem hiding this comment.
simplification: the prefix is known at macro time (generate_const_definitions already uses it), so bake it into the literals and drop this runtime pass that leaks a prefixed copy of every name.
| /// via `--list-config-env-vars`, but still non-config. Included in | ||
| /// `SERVER_PROCESS_ENV_VARS` to suppress "unknown env var" warnings during | ||
| /// config scanning. | ||
| pub const SERVER_SCAN_ONLY_ENV_VARS: &[&str] = &[ |
There was a problem hiding this comment.
simplification: keep scan-only and advertised as two disjoint lists and expose the union through one pub fn for the scan, the tests and the harness - then this const can be private too.
Implement --list-config-env-vars flag for iggy-server, iggy-connectors, and iggy-mcp.
Closes #4322
Problem
Users need a way to discover supported environment variables before loading configuration, useful for:
Solution
Added --list-config-env-vars flag to all three binaries that:
Implementation Details
Testing
Integration test validates: