This is an automated email from the ASF dual-hosted git repository.

hubcio pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/master by this push:
     new f4222f09c fix(configs): make environment variable name suggestions 
deterministic (#3142)
f4222f09c is described below

commit f4222f09c4ab6c54770433013c665d9dafa626ab
Author: Alan Tang <[email protected]>
AuthorDate: Wed Apr 22 15:57:58 2026 +0800

    fix(configs): make environment variable name suggestions deterministic 
(#3142)
---
 core/configs/src/configs_impl/typed_env_provider.rs | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/core/configs/src/configs_impl/typed_env_provider.rs 
b/core/configs/src/configs_impl/typed_env_provider.rs
index 41b0c19a9..a914cde53 100644
--- a/core/configs/src/configs_impl/typed_env_provider.rs
+++ b/core/configs/src/configs_impl/typed_env_provider.rs
@@ -353,7 +353,10 @@ impl<T: ConfigEnvMappings> TypedEnvProvider<T> {
             })
             .collect();
 
-        suggestions.sort_by_key(|(_, dist)| *dist);
+        suggestions.sort_by(|(var_a, dist_a), (var_b, dist_b)| {
+            dist_a.cmp(dist_b).then_with(|| var_a.cmp(var_b))
+        });
+
         suggestions.truncate(3);
         suggestions.into_iter().map(|(s, _)| s).collect()
     }
@@ -528,6 +531,14 @@ mod tests {
         assert!(suggestions.len() <= 3);
     }
 
+    #[test]
+    fn find_similar_vars_has_deterministic_order_for_same_distance() {
+        let known: HashSet<&str> = ["VAR_D", "VAR_B", "VAR_A", 
"VAR_C"].into_iter().collect();
+
+        let suggestions = 
TypedEnvProvider::<TestConfig>::find_similar_vars("VAR_Z", &known);
+        assert_eq!(suggestions, vec!["VAR_A", "VAR_B", "VAR_C"]);
+    }
+
     #[test]
     fn test_config_generates_env_mappings() {
         let mappings = TestConfig::env_mappings();

Reply via email to