← Back to issue list

[WIP] Fix fetch-lib error in charmcraft causing library not found

View original Github issue

Metadata

Project
charmcraft
Number
#2503
Type
pull request
State
closed
Author
Copilot
Labels
—
Created
Updated
Closed

Current evaluation

PR #2503 was closed unmerged as unfinished WIP; tests, review, and security checks were not completed. The fetch-lib “Library None” bug remains, while PR #2505 is still open.

Resolution: closed stale

Reason: The PR remained marked WIP, with tests, review, and security checks unfinished and no completed CI checks or comments. It closed without merging; issue #2204 remains open and alternative PR #2505 has not been merged.

Evaluated by: mr-cal-bot

No scores available.

Issue body

## Fix error message for fetch-lib command when library is None - [x] Understand the issue: When `charmcraft fetch-lib` is run without arguments to update all libraries, and a library is not found in Charmhub, the error message incorrectly shows "Library None not found in Charmhub." instead of showing the actual library name - [x] Identify the root cause: Two locations in `store.py` use `parsed_args.library` in error messages (lines 1539 and 1562), but when running without arguments, `parsed_args.library` is None - [x] Fix line 1539: Removed the try-except block that was re-raising with `parsed_args.library`, allowing the more detailed error from `get_libraries_metadata()` to propagate - [x] Fix line 1562: Use `lib_data.full_name` instead of `parsed_args.library` in the error message - [ ] Create/update tests to validate the fix - [ ] Run existing tests to ensure no regressions - [ ] Request code review - [ ] Run security checks <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> ---- *This section details on the original issue you should resolve* <issue_title>[3.4.3] Charmcraft fetch-lib fails with `Library None not found in Charmhub.`</issue_title> <issue_description>### Bug Description I am using charmcraft: `installed: 3.4.3.post51+g6153055c (6228) 60MB classic` Installed from channel `latest/edge` We have done some few changes in the OpenSearch libs and now the `check_libs` started failing with an error instead of simply a list of outdated libs. Running it locally and I can also reproduce the same error. This error message is not really helpful and the logs print the entire lib content, making it hard to read. ### To Reproduce $ git clone https://github.com/canonical/opensearch-operator -b 2/edge $ cd opensearch-operator $ charmcraft fetch-lib Library None not found in Charmhub. ### Environment OS: 24.04 charmcraft: latest/edge, currently on 3.4.3 ### charmcraft.yaml ```yaml # Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. type: charm platforms: ubuntu@22.04:amd64: ubuntu@24.04:amd64: # Files implicitly created by charmcraft without a part: # - dispatch (https://github.com/canonical/charmcraft/pull/1898) # - manifest.yaml # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L259) # Files implicitly copied/"staged" by charmcraft without a part: # - actions.yaml, config.yaml, metadata.yaml # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L290-L293 # https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L156-L157) parts: # "poetry-deps" part name is a magic constant # https://github.com/canonical/craft-parts/pull/901 poetry-deps: plugin: nil build-packages: - curl override-build: | # Use environment variable instead of `--break-system-packages` to avoid failing on older # versions of pip that do not recognize `--break-system-packages` # `--user` needed (in addition to `--break-system-packages`) for Ubuntu >=24.04 PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest # Use uv to install poetry so that a newer version of Python can be installed if needed by poetry curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.15/uv-installer.sh | sh # renovate: charmcraft-uv-latest # poetry 2.0.0 requires Python >=3.9 if ! "$HOME/.local/bin/uv" python find '>=3.9' then # Use first Python version that is >=3.9 and available in an Ubuntu LTS # (to reduce the number of Python versions we use) "$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04 fi "$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.0.0 --with poetry-plugin-export==1.8.0 # renovate: charmcraft-poetry-latest ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry # "charm-poetry" part name is arbitrary; use for consistency # Avoid using "charm" part name since that has special meaning to charmcraft charm-poetry: # By default, the `poetry` plugin creates/stages these directories: # - lib, src # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78) # - venv # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95 # https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270) plugin: poetry source: . after: - poetry-deps poetry-export-extra-args: ['--only', 'main,charm-libs'] build-packages: - libffi-dev # Needed to build Python dependencies with Rust from source - libssl-dev # Needed to build Python dependencies with Rust from source - pkg-config # Needed to build Python dependencies with Rust from source override-build: | # Workaround for https://github.com/canonical/charmcraft/issues/2068 # rustup used to install rustc and cargo, which are needed to build Python dependencies with Rust from source if [[ "$CRAFT_PLATFORM" == ubuntu@20.04:* || "$CRAFT_PLATFORM" == ubuntu@22.04:* ]] then snap install rustup --classic else apt-get install rustup -y fi # If Ubuntu version < 24.04, rustup was installed from snap instead of from the Ubuntu # archive—which means the rustup version could be updated at any time. Print rustup version # to build log to make changes to the snap's rustup version easier to track rustup --version # rpds-py (Python package) >=0.19.0 requires rustc >=1.76, which is not available in the... </details> - Fixes canonical/charmcraft#2204 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed stale PR #2503 was closed unmerged as unfinished WIP; tests, review, and security checks were not completed. The fetch-lib “Library None” bug remains, while PR #2505 is still open.
stealth/space-bunny-alpha — closed stale PR #2504 was closed unmerged and abandoned as WIP; tests, review, and security checks remained unfinished, with no CI results or comments.
qwen/qwen3.6-35b-a3b — — Closed as abandoned. The PR aimed to fix an incorrect "Library None not found" error in charmcraft's fetch-lib by updating store.py. Marked WIP and AI-generated, it lacked tests and review, so it was closed without merging.
qwen3.6-35b-a3b-mtp-q6 — — Closed without merging. The pull request addressed a charmcraft fetch-lib error showing Library None not found by updating store.py error handling. Marked as WIP with pending tests and review, it was abandoned without completion.

Update history

No update history recorded yet.

Related work

Related issues

Issue Project State Summary Similarity
#2504 [WIP] Fix fetch-lib error in charmcraft 3.4.3 charmcraft closed Closed unmerged without tests, review, or CodeQL; the WIP fix was abandoned, while follow-up PR #2505 remains open for issue #2204.
92%
#2505 fix: fetch-lib error message showing "Library None not found" charmcraft open Fixes misleading 'Library None not found' error in `charmcraft fetch-lib` by using `lib_data.full_name` instead of `parsed_args.library`. PR is approved with CI passing but has 1 unresolved review comment.
78%
#2204 [3.4.3] Charmcraft fetch-lib fails with `Library None not found in Charmhub.` charmcraft open Bulk fetch-lib aborts on an unavailable local library and misleadingly prints “Library None not found”; current code still uses the absent CLI argument, while PR #2505 remains open.
77%
#1663 refactor: remove unused fetch-lib command charmcraft merged PR #1663 (commit b3d35e6d) merged, deleting the unused pre-craft-application fetch-lib implementation; the public fetch-lib command was kept and #1665 added fetch-libs for charmcraft.yaml-declared libraries.
71%
#1788 `fetch-lib` should work from anywhere charmcraft open `fetch-lib` regressed in Charmcraft 3.1.1 by requiring charmcraft.yaml outside projects; a minimal reproducer was provided, and a maintainer explicitly kept the compatibility request open.
70%