Skip to content

_stream: use full element name in artifact log/list-contents - #2174

Open
c1assik wants to merge 1 commit into
apache:masterfrom
c1assik:fix/artifact_full_name
Open

_stream: use full element name in artifact log/list-contents#2174
c1assik wants to merge 1 commit into
apache:masterfrom
c1assik:fix/artifact_full_name

Conversation

@c1assik

@c1assik c1assik commented Aug 15, 2026

Copy link
Copy Markdown

artifact_log() and artifact_list_contents() were keying their result dicts by obj.name, which is just the bare, project-relative element name. For elements loaded across a junction, this drops the owning junction prefix, so e.g. bst artifact list-contents element.bst nested.bst:element.bst would only show one entry, since both targets resolved to the same key.

Use obj._get_full_name() instead, which includes the junction prefix, falling back to the artifact ref for ArtifactElement targets (i.e. when an artifact is referred to by its ref rather than its element name) as before.

Also drops a dead obj.name = {ref: "No artifact cached"} assignment in artifact_list_contents() that was immediately followed by continue and never used.

Add tests covering artifact log and artifact list-contents with a cross-junction element alongside a same-named top-level element.

@c1assik
c1assik marked this pull request as ready for review August 15, 2026 09:08
Comment thread src/buildstream/_stream.py Outdated
continue

artifact_logs[obj.name] = obj._get_logs()
name = ref if isinstance(obj, ArtifactElement) else obj._get_full_name()

@nathanwilliams-ct nathanwilliams-ct Aug 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better if ArtifactElement overrode the _get_full_name method or the __full_name variable, instead of having this awkward condition here?

Suggested change
name = ref if isinstance(obj, ArtifactElement) else obj._get_full_name()
name = obj._get_full_name()

In ArtifactElement

def _get_full_name(self)
   return self.get_artifact_name()

@c1assik c1assik Aug 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a method _get_full_name() to ArtifactElement.

return self.get_artifact_name(), unconditionally fails with AssertionError: assert key is not None in get_artifact_name() so if the cache key isn't set yet, fall back to super()._get_full_name() (the base Plugin/Element name, which is always safe since it's precomputed earlier in Plugin.init). Once construction finishes and the key is set, it returns the full artifact ref as intended

`artifact_log()` and `artifact_list_contents()` were keying their
result dicts by `obj.name`, which is just the bare, project-relative
element name. For elements loaded across a junction, this drops the
owning junction prefix, so e.g. `bst artifact list-contents
element.bst nested.bst:element.bst` would only show one entry, since
both targets resolved to the same key.

Use `obj._get_full_name()` instead, which includes the junction
prefix, falling back to the artifact ref for `ArtifactElement`
targets (i.e. when an artifact is referred to by its ref rather than
its element name) as before.

Also drops a dead `obj.name = {ref: "No artifact cached"}` assignment
in `artifact_list_contents()` that was immediately followed by
`continue` and never used.

Add tests covering `artifact log` and `artifact list-contents` with a
cross-junction element alongside a same-named top-level element.
@c1assik
c1assik force-pushed the fix/artifact_full_name branch from cdbdea6 to 30fd1a2 Compare August 17, 2026 17:18
@nathanwilliams-ct

Copy link
Copy Markdown
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants