joshua-zivkovic commented on code in PR #2099:
URL: https://github.com/apache/buildstream/pull/2099#discussion_r2707171878


##########
src/buildstream/source.py:
##########
@@ -1393,23 +1410,33 @@ def create_source_info(
 
         *Since: 2.5*
         """
-        homepage = None
-        issue_tracker = None
+        project = self._get_project()
 
+        provenance: SourceProvenance | None
         if provenance_node is not None:
-            provenance: Optional[_SourceProvenance] = 
_SourceProvenance.new_from_node(provenance_node)
+            # Ensure provenance node keys are valid and values are all strings
+            defined_provenance_fields = (
+                project._project_conf.get_mapping("source-provenance-fields", 
None) or project.source_provenance_fields
+            )
+
+            try:
+                provenance_node.validate_keys(defined_provenance_fields.keys())
+            except LoadError as E:
+                raise LoadError(
+                    "Specified source attribute not defined in project 
config\n {}".format(E),
+                    LoadErrorReason.UNDEFINED_SOURCE_PROVENANCE_ATTRIBUTE,
+                )
+
+            # Make sure everything is a string
+            provenance = MappingNode.from_dict({key: value.as_str() for key, 
value in provenance_node.items()})

Review Comment:
   I wasn't aware I could simply write back to a `MappingNode` like a 
dictionary, even though the docs clearly state that. Regardless, this is no 
longer being used since this logic has been changed to throwing an error in the 
event that the value could not be parsed as a string



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to