diff --git a/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py b/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py index 6179b297..2c0ee616 100644 --- a/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py +++ b/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py @@ -318,6 +318,7 @@ def parse_stability(stability, position_data, attr_id, validation_ctx): msg = f"Value '{stability}' is not allowed as a stability marker" validation_ctx.raise_or_warn(position_data["stability"], msg, attr_id) + return None @staticmethod def parse_deprecated(deprecated, position_data, attr_id, validation_ctx): @@ -442,6 +443,7 @@ def to_bool(key, parent_object, validation_ctx): msg, parent_object.get("id"), ) + return None @dataclass @@ -531,7 +533,7 @@ def parse(attribute_type, position, validation_ctx): validation_ctx.raise_or_warn( myaml.lc.data["value"], f"Enumeration member does not have type {enum_type}!", - enum_type.get("id"), + m.member_id, ) return EnumAttributeType(custom_values, members, enum_type) diff --git a/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py b/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py index 42c26b00..5c72f78f 100644 --- a/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py +++ b/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py @@ -75,7 +75,7 @@ def parse_semantic_convention_groups(yaml_file, validation_ctx): def SemanticConvention(group, validation_ctx): type_value = group.get("type") - id = group.get("id") + semconv_id = group.get("id") if type_value is None: line = group.lc.data["id"][0] + 1 doc_url = "https://github.com/open-telemetry/build-tools/blob/main/semantic-conventions/syntax.md#groups" @@ -88,7 +88,7 @@ def SemanticConvention(group, validation_ctx): if convention_type is None: position = group.lc.data["type"] if "type" in group else group.lc.data["id"] msg = f"Invalid value for semantic convention type: {group.get('type')}" - validation_ctx.raise_or_warn(position, msg, id) + validation_ctx.raise_or_warn(position, msg, semconv_id) # First, validate that the correct fields are available in the yaml convention_type.validate_keys(group, validation_ctx) @@ -313,6 +313,7 @@ class SemanticConventionSet: debug: bool models: typing.Dict[str, BaseSemanticConvention] = field(default_factory=dict) errors: bool = False + validation_ctx: ValidationContext = None def parse(self, file, validation_ctx=None): self.validation_ctx = validation_ctx or ValidationContext(file, True) @@ -398,7 +399,7 @@ def _populate_extends_single(self, semconv, unprocessed): Resolves the parent/child relationship for a single Semantic Convention. If the parent **p** of the input semantic convention **i** has in turn a parent **pp**, it recursively resolves **pp** before processing **p**. :param semconv: The semantic convention for which resolve the parent/child relationship. - :param semconvs: The list of remaining semantic conventions to process. + :param unprocessed: The list of remaining semantic conventions to process. :return: A list of remaining semantic convention to process. """ # Resolve parent of current Semantic Convention @@ -406,7 +407,7 @@ def _populate_extends_single(self, semconv, unprocessed): extended = self.models.get(semconv.extends) if extended is None: self.validation_ctx.raise_or_warn( - self._position, + semconv._position, f"Semantic Convention {semconv.semconv_id} extends " f"{semconv.extends} but the latter cannot be found!", semconv.semconv_id, diff --git a/semantic-conventions/src/opentelemetry/semconv/model/utils.py b/semantic-conventions/src/opentelemetry/semconv/model/utils.py index 68c205da..391acc2b 100644 --- a/semantic-conventions/src/opentelemetry/semconv/model/utils.py +++ b/semantic-conventions/src/opentelemetry/semconv/model/utils.py @@ -34,12 +34,12 @@ def validate_id(semconv_id, position, validation_ctx): def validate_values(yaml, keys, validation_ctx, mandatory=()): """This method checks only valid keywords and value types are used""" - id = yaml.get("id") + node_id = yaml.get("id") unwanted = [k for k in yaml.keys() if k not in keys] if unwanted: position = yaml.lc.data[unwanted[0]] msg = f"Invalid keys: {unwanted}" - validation_ctx.raise_or_warn(position, msg, id) + validation_ctx.raise_or_warn(position, msg, node_id) if mandatory: check_no_missing_keys(yaml, mandatory, validation_ctx) @@ -95,5 +95,4 @@ def raise_or_warn(self, pos, msg, fqn): error = ValidationError(pos[0] + 1, pos[1] + 1, msg, fqn) if self.strict_validation: raise error - else: - print(f"[Warning] {self.file_name}: {error}\n") + print(f"[Warning] {self.file_name}: {error}\n")