juergbi commented on code in PR #2099:
URL: https://github.com/apache/buildstream/pull/2099#discussion_r2697949571
##########
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:
Is there a reason we actually need to use a newly created `MappingNode`
instead of directly using `provenance_node` (after verification)? I suspect
that this recreation loses provenance of the provenance node (i.e., `.bst` file
name and line number).
--
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]