kotborealis opened a new issue, #2118: URL: https://github.com/apache/buildstream/issues/2118
Found a subtle bug while using self-junctions. See [reproduction](https://github.com/kotborealis/buildstream-self-junction-override-bug). The project contains [self-junction](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/self_junction.bst) - which loads current project as a junction. This self-junction overrides element [thing.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/thing.bst) with [thing_override.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/thing_override.bst). It all works until i introduce another junction [subproject.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/subproject.bst) and [include yaml from it in project.conf](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/project.conf#L16C1-L17C1). Then, when trying to override [thing.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/thing.bst) with [thing_override.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/thing_override.bst), i get the following error: ``` self_junction.bst:thing.bst [line 4 column 4]: Failed to evaluate expression (some_option == "x"): 'some_option' is undefined ``` Overriding [thing.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/elements/thing.bst) evaluates it, catches on conditionals and breaks down on undefined variables. The [include yaml from subproject.bst](https://github.com/kotborealis/buildstream-self-junction-override-bug/blob/main/project.conf#L16C1-L17C1) acts like a trigger for this issue. Without this include everything works fine. For now I found a workaround for this bug - to hide conditions in thing.bst nested in a stack. Also I've tried to fix it by patching sources, but I'm not sure if its the right fix. ```patch diff --git a/src/buildstream/_includes.py b/src/buildstream/_includes.py index 5eefd0b59..d7dc17fff 100644 --- a/src/buildstream/_includes.py +++ b/src/buildstream/_includes.py @@ -61,7 +61,13 @@ class Includes: current_loader = self._loader if process_project_options: - current_loader.project.options.process_node(node) + project = current_loader.project + # During re-entrant loading (e.g. self-junction + nested includes), + # a project may be marked fully loaded before second-pass options are + # initialized. Use first-pass options until second-pass base variables + # exist, which indicates _load_pass() for the second pass has run. + options = project.config.options if project.config.base_variables is not None else project.first_pass_config.options + options.process_node(node) self._process_node( node, ``` -- 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]
