← Back to issue list

Organize does not raise error if source file does not exist

View original Github issue

Metadata

Project
craft-parts
Number
#553
Type
issue
State
open
Author
amandahla
Labels
Created
Updated
Closed

Current evaluation

craft-parts organize silently succeeds when a non-glob source file does not exist, so a renamed/missing file in a rockcraft.yaml organize mapping is not caught at build time. Maintainer confirmed root cause (empty glob iterator) in 2023; no fix landed.

Suggested action: keep open

Reason: Maintainer tigarmo diagnosed the root cause on 2023-09-15 (empty glob iterator in organize.py means a missing non-glob source is silently skipped), and the current code still uses base.glob() with no error when src_count == 0, so the bug is unfixed. It is a real correctness bug (silent missing files in built rocks) with a clear, small fix, but it has no labels/assignee and no recent activity, so it should stay open pending triage rather than be closed.

Impact: 55 Quick Win: 33.0 Staleness: 62 Complexity: 40 Confidence: 80 Support Request: 5

Issue body

### Bug Description While building a rock for Synapse charm, there is a configuration file that should be dumped in a specific directory with a specific name by using the "organize" keyword. Its name was changed in the repository but not in the rockcraft.yaml. This went unnoticed until deploying the charm because the rock was successfully built but the file was not there. ### To Reproduce This is an example of the part that was expected to raise an error since the source file in "organize" does not exist. not-found-login_ubuntu.py is a file that does not exist. ``` synapse-conf: plugin: dump source: attributemaps organize: not-found-login_ubuntu.py: /usr/local/attributemaps/login_ubuntu.py ``` ### part yaml ```shell # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. name: synapse summary: Synapse rock description: Synapse OCI image for the Synapse charm version: "1.0" base: ubuntu:22.04 build-base: ubuntu:22.04 license: Apache-2.0 platforms: amd64: parts: synapse: build-packages: - build-essential - curl - git - libffi-dev - libssl-dev - pkg-config - libjpeg-dev - libpq-dev - libwebp-dev - libxml++2.6-dev - libxslt1-dev - openssl - zlib1g-dev - libicu-dev - python3-dev - python3-pip - python3-setuptools stage-packages: - bash - coreutils - curl - gosu - libffi-dev - libjpeg-turbo8 - libpq5 - libwebp7 - xmlsec1 - libjemalloc2 - libicu70 - libssl-dev - openssl - python3 plugin: nil source: https://github.com/matrix-org/synapse/ source-type: git source-tag: v1.85.2 override-build: | craftctl default export RUSTUP_HOME=/rust export CARGO_HOME=/cargo export PATH=/cargo/bin:/rust/bin:$PATH export CARGO_NET_GIT_FETCH_WITH_CLI=false mkdir -p /rust /cargo /synapse /install curl -m 30 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal pip3 install -U pip setuptools pip3 install --root-user-action=ignore "poetry==1.3.2" cp pyproject.toml poetry.lock /synapse/ /usr/local/bin/poetry export --extras all -o /synapse/requirements.txt pip3 install --prefix="/install" --no-deps --no-warn-script-location -r /synapse/requirements.txt cp -r synapse /synapse/ cp -r rust /synapse/ cp pyproject.toml README.rst build_rust.py Cargo.toml Cargo.lock /synapse/ pip3 install --prefix="/install" --no-deps --no-warn-script-location /synapse[all]; cp docker/start.py $CRAFT_PART_INSTALL/ chmod 755 $CRAFT_PART_INSTALL/start.py sed -i 's/#!\/usr\/local\/bin\/python/#!\/usr\/bin\/python3/' $CRAFT_PART_INSTALL/start.py cp -r docker/conf $CRAFT_PART_INSTALL/ cp -r /usr/local $CRAFT_PART_INSTALL/usr/ cp -r /install/local/* $CRAFT_PART_INSTALL/usr/local/ mkdir -p $CRAFT_PART_INSTALL/usr/local/attributemaps chmod 755 $CRAFT_PART_INSTALL/usr/local/attributemaps synapse-conf: plugin: dump source: attributemaps organize: u1staging.py: /usr/local/attributemaps/u1staging.py ``` ### Relevant log output ```shell 2023-09-13T20:31:10.7322269Z 2023-09-13 20:31:05.623 Executed: build synapse 2023-09-13T20:31:10.7322656Z 2023-09-13 20:31:05.623 Executing parts lifecycle: build synapse-conf 2023-09-13T20:31:10.7323025Z 2023-09-13 20:31:05.623 Executing action 2023-09-13T20:31:10.7323789Z 2023-09-13 20:31:05.627 execute action synapse-conf:Action(part_name='synapse-conf', step=Step.BUILD, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2023-09-13T20:31:10.7324443Z 2023-09-13 20:31:05.628 load state file: /root/parts/synapse-conf/state/pull 2023-09-13T20:31:10.7324897Z 2023-09-13 20:31:05.635 remove directory /root/parts/synapse-conf/build 2023-09-13T20:31:10.7325894Z 2023-09-13 20:31:05.637 Executing PosixPath('/root/parts/synapse-conf/run/build.sh') 2023-09-13T20:31:10.7326621Z 2023-09-13 20:31:05.644 :: + cp --archive --link --no-dereference . /root/parts/synapse-conf/install 2023-09-13T20:31:10.7327037Z 2023-09-13 20:31:06.424 Executed: build synapse-conf 2023-09-13T20:31:10.7327436Z 2023-09-13 20:31:06.425 Executing parts lifecycle: stage pebble ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 55
Quick Win: 33.0
Staleness: 62
Complexity: 40
Confidence: 80
Support Request: 5
keep open craft-parts organize silently succeeds when a non-glob source file does not exist, so a renamed/missing file in a rockcraft.yaml organize mapping is not caught at build time. Maintainer confirmed root cause (empty glob iterator) in 2023; no fix landed.
qwen/qwen3.8-27b
Impact: 50
Quick Win: 32.5
Staleness: 70
Complexity: 35
Confidence: 80
Support Request: 5
keep open craft-parts 'organize' silently succeeds when a mapped source file does not exist, because the glob expansion yields an empty iterator and the loop is skipped. Maintainer confirmed root cause in 2023; no fix found in current code or history. Open, unlabelled, last activity 538 days ago.
qwen/qwen3.6-35b-a3b
Staleness: 92
Complexity: 20
Confidence: 80
Support Request: 10
needs triage Bug report where craft-parts organize silently ignores missing source files instead of raising an error. Unlabeled and unresponded to by maintainers for over two years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 30
Confidence: 80
Support Request: 5
needs triage Bug report stating organize silently succeeds when source files are missing. Open for nearly three years with no maintainer labels or response, though a contributor identified the likely code cause.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 30
Confidence: 60
Support Request: 5
needs triage The organize keyword silently ignores missing source files instead of raising an error. Likely caused by an empty iglob iterator. Issue remains open with Jira ticket CRAFT-2943 created. Last activity 465 days ago.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1663233 Confusing error message for "organize" when source refers to multiples items and destination doesn't end up with / snapcraft (launchpad) open Snapcraft 2.26 (2017) reports a misleading 'already exists' error when an organize glob matches multiple items and the destination lacks a trailing slash; reporter suggests auto-treating the destination as a directory. No maintainer response; code has since moved to craft-parts.
71%
#1844801 Organize has different move behavior when using wildcard snapcraft (launchpad) open Snapcraft organize keyword moves directory contents for literal paths but the directory itself for glob/wildcard paths, causing confusing 'already exists' errors. No maintainer response in 7 years; behavior still present in craft-parts organize code. Needs triage.
70%