Skip to content

fix(executor): handle empty-string organize path - #1532

Open
gcomneno wants to merge 3 commits into
canonical:mainfrom
gcomneno:contrib/issue-1526-empty-organize
Open

fix(executor): handle empty-string organize path#1532
gcomneno wants to merge 3 commits into
canonical:mainfrom
gcomneno:contrib/issue-1526-empty-organize

Conversation

@gcomneno

@gcomneno gcomneno commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Handle organize: {'': ''} as a no-op when the source and destination resolve to the same directory.

Testing

  • pytest -q tests/integration/executor/test_organize.py -rs
  • pytest -q tests/integration/executor/test_environment.py -k expand_environment -rs

Issue

Closes #1526

AI assistance

AI assistance was used while addressing review feedback and validating this follow-up. I reviewed and understand the resulting code and tests and remain responsible for the contribution.

@gcomneno
gcomneno requested a review from a team as a code owner April 3, 2026 16:31
@gcomneno
gcomneno force-pushed the contrib/issue-1526-empty-organize branch 2 times, most recently from 6693057 to fe5f1af Compare May 24, 2026 14:54
@lengau
lengau requested review from cmatsuoka and Copilot May 26, 2026 20:25

Copilot AI left a comment

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.

Pull request overview

Fixes an edge case in the executor’s organize step where an empty-string mapping (organize: {'': ''}) could trigger a self-organize of the install directory, causing content to be removed during the move/copy process. The change makes this mapping a no-op when source and destination resolve to the same directory, and adds an integration test to prevent regressions.

Changes:

  • Skip directory organize operations when the resolved destination path equals the source path (prevents self-copy + delete).
  • Adjust get_src_path() validation to correctly handle empty source paths by validating the source directory itself.
  • Add an integration test covering organize: {'': ''} during Step.PRIME.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
craft_parts/executor/organize.py Prevents organizing a directory onto itself and fixes path validation for empty organize keys.
tests/integration/executor/test_organize.py Adds an integration test to ensure empty-string organize mappings are treated as a no-op.

@gcomneno

Copy link
Copy Markdown
Contributor Author

Friendly ping on this PR. It has been idle for a while, and it should still be ready from my side.

Please let me know if you would like me to rebase, refresh the checks, or adjust anything else.

Thanks!

@gcomneno
gcomneno force-pushed the contrib/issue-1526-empty-organize branch from 62e61f6 to 7d62fee Compare July 31, 2026 10:44
Comment thread craft_parts/executor/organize.py Outdated
real_dst_path = dst_path.resolve()
else:
real_dst_path = dst_path
if real_dst_path == src_path:

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.

We should check this with samefile() so we can handle some more esoteric cases.

@lengau lengau left a comment

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.

LGTM other than one minor nit. Thanks!

(Sorry for the belated review)

@gcomneno

Copy link
Copy Markdown
Contributor Author

CI note: the only failing QA job is test-java-plugins / Slow tests (noble, s390x, edge, 3.12).

The failures are JVM-level crashes on s390x (a native allocation failure in Gradle and an OpenJDK SIGSEGV during Maven), while the rest of the matrix passes. The same s390x Java job also passed on a recent main QA run.

I do not have repository write permission to re-run the job. Could someone with access please retry it?

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.

Strange behaviour when organizing from an empty string

3 participants