diff --git a/crates/weaver_checker/src/lib.rs b/crates/weaver_checker/src/lib.rs index d8c629e1f..3e368d11c 100644 --- a/crates/weaver_checker/src/lib.rs +++ b/crates/weaver_checker/src/lib.rs @@ -312,14 +312,6 @@ impl Engine { policy_dir: P, policy_glob_pattern: &str, ) -> Result { - fn is_hidden(entry: &DirEntry) -> bool { - entry - .file_name() - .to_str() - .map(|s| s.starts_with('.')) - .unwrap_or(false) - } - let mut errors = Vec::new(); let mut added_policy_count = 0; @@ -335,11 +327,8 @@ impl Engine { policy_glob.is_match(path.as_ref()) }; - // Visit recursively all the files in the policy directory + // Visit recursively all the files in the policy directory. for entry in walkdir::WalkDir::new(policy_dir).into_iter().flatten() { - if is_hidden(&entry) { - continue; - } if is_policy_file(&entry) { if let Err(err) = self.add_policy_from_file(entry.path()) { errors.push(err); diff --git a/crates/weaver_resolver/src/lib.rs b/crates/weaver_resolver/src/lib.rs index 60cfafa87..a7e406be3 100644 --- a/crates/weaver_resolver/src/lib.rs +++ b/crates/weaver_resolver/src/lib.rs @@ -285,14 +285,7 @@ impl SchemaResolver { visited_registries: &mut HashSet, dependency_chain: &mut Vec, ) -> WResult, weaver_semconv::Error> { - // Define helper functions for filtering files. - fn is_hidden(entry: &DirEntry) -> bool { - entry - .file_name() - .to_str() - .map(|s| s.starts_with('.')) - .unwrap_or(false) - } + // Define helper function for filtering files. fn is_semantic_convention_file(entry: &DirEntry) -> bool { let path = entry.path(); let extension = path.extension().unwrap_or_else(|| std::ffi::OsStr::new("")); @@ -331,7 +324,6 @@ impl SchemaResolver { let result = walkdir::WalkDir::new(local_path.clone()) .follow_links(follow_symlinks) .into_iter() - .filter_entry(|e| !is_hidden(e)) .par_bridge() .flat_map(|entry| { match entry { diff --git a/crates/weaver_semconv/src/v2/attribute_group.rs b/crates/weaver_semconv/src/v2/attribute_group.rs index 1757a3918..800b6dbf0 100644 --- a/crates/weaver_semconv/src/v2/attribute_group.rs +++ b/crates/weaver_semconv/src/v2/attribute_group.rs @@ -173,21 +173,16 @@ impl AttributeGroup { } /// The group's visibility. -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, JsonSchema, Default)] #[serde(rename_all = "snake_case")] pub enum AttributeGroupVisibilitySpec { /// An internal group. + #[default] Internal, /// A public group. Public, } -impl Default for AttributeGroupVisibilitySpec { - fn default() -> Self { - Self::Internal - } -} - impl std::fmt::Display for AttributeGroupVisibilitySpec { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { diff --git a/test_data/.hidden_reg/.test.yaml b/test_data/.hidden_reg/.test.yaml new file mode 100644 index 000000000..612e1f2fa --- /dev/null +++ b/test_data/.hidden_reg/.test.yaml @@ -0,0 +1,8 @@ +groups: + - id: test.group + type: span + brief: Minimal test group for issue 958 + attributes: + - id: test.attr + type: string + brief: Test attribute diff --git a/tests/registry_generate.rs b/tests/registry_generate.rs index fd38a83b3..6ad534529 100644 --- a/tests/registry_generate.rs +++ b/tests/registry_generate.rs @@ -48,3 +48,22 @@ fn test_cli_interface() { // We expect 31 policy violations. assert_eq!(json_value.len(), 31); } + +/// Test for issue #958: Registry paths beginning with '.' should work +#[test] +fn test_hidden_directory() { + let mut cmd = Command::cargo_bin("weaver").unwrap(); + let output = cmd + .arg("registry") + .arg("resolve") + .arg("-r") + .arg("test_data/.hidden_reg") + .timeout(std::time::Duration::from_secs(60)) + .output() + .expect("failed to execute process"); + + assert!(output.status.success()); + + let stderr = String::from_utf8(output.stderr).expect("Invalid UTF-8"); + assert!(stderr.contains("loaded (1 files)")); +}