`fetch-libs` has weird error messages when libs aren't available
Metadata
Current evaluation
Fixed misleading fetch-libs errors for unavailable libraries in merged PR #2034 (commit c9b51038), with a clearer missing-library message.
Resolution: closed resolved
Reason: PR #2034 was merged with commit c9b51038, replacing Charmhub's unclear missing-library response with an actionable fetch-libs error. The fix is present in charmcraft/services/store.py.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
Example: https://github.com/canonical/charmcraft/actions/runs/10049710901/job/27776909923#step:5:1228
When libraries aren't available from charmhub, `fetch-libs` doesn't always respond with a valid error message.
### To Reproduce
Use the `resources` spread test, but pointed at charmhub staging
### Environment
CI
### charmcraft.yaml
```shell
The output of `charmcraft init --profile flask-framework`
```
### Relevant log output
```shell
+ charmcraft fetch-libs
2024-07-22 23:34:31.157 Starting charmcraft, version 3.0.0.post96+g3b05ba5
2024-07-22 23:34:31.157 Logging execution to '/root/.local/state/charmcraft/log/charmcraft-20240722-233431.156756.log'
2024-07-22 23:34:31.157 Log verbosity level set to DEBUG
2024-07-22 23:34:31.157 Configuring application...
2024-07-22 23:34:31.157 Preparing application...
2024-07-22 23:34:31.158 Build plan: platform=None, build_for=None
2024-07-22 23:34:31.158 Loading project file '/charmcraft/tests/spread/commands/init-flask-framework/test-init/charmcraft.yaml'
2024-07-22 23:34:31.163 Processing grammar (on amd64 for amd64)
2024-07-22 23:34:31.163 Processing grammar for plugin: charm
2024-07-22 23:34:31.163 Processing grammar for source: .
2024-07-22 23:34:31.163 Processing grammar for build-snaps: ['rustup']
2024-07-22 23:34:31.165 Running charmcraft fetch-libs on host
2024-07-22 23:34:31.166 Setting up StoreService
2024-07-22 23:34:33.211 Falling back to file based storage
2024-07-22 23:34:33.212 Getting library metadata from charmhub
2024-07-22 23:34:33.213 HTTP 'POST' for 'https://api.staging.charmhub.io/v1/charm/libraries/bulk' with params None and headers {'User-Agent': 'charmcraft/3.0.0.post96+g3b05ba5 ubuntu/22.04 (x86_64) python/3.10.12'}
2024-07-22 23:34:34.588 charmcraft internal error: StoreServerError("Store operation failed:\n- None: Items need to include 'library_id' or 'package_id'")
2024-07-22 23:34:34.595 Traceback (most recent call last):
2024-07-22 23:34:34.596 File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/application.py", line 538, in run
2024-07-22 23:34:34.596 return_code = dispatcher.run() or 0
2024-07-22 23:34:34.596 File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
2024-07-22 23:34:34.596 return self._loaded_command.run(self._parsed_command_args)
2024-07-22 23:34:34.596 File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/application/commands/store.py", line 1681, in run
2024-07-22 23:34:34.596 libs_metadata = store.get_libraries_metadata_by_name(charm_libs)
2024-07-22 23:34:34.596 File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/services/store.py", line 248, in get_libraries_metadata_by_name
2024-07-22 23:34:34.596 for lib in self.get_libraries_metadata(libraries)
2024-07-22 23:34:34.596 File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/services/store.py", line 240, in get_libraries_metadata
2024-07-22 23:34:34.597 return self.anonymous_client.fetch_libraries_metadata(store_libs)
2024-07-22 23:34:34.597 File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/store/client.py", line 103, in fetch_libraries_metadata
2024-07-22 23:34:34.597 response = self.request_urlpath_json("POST", "/v1/charm/libraries/bulk", json=libs)
2024-07-22 23:34:34.597 File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/store/client.py", line 64, in request_urlpath_json
2024-07-22 23:34:34.597 response = self._http_client.request(method, self.api_base_url + urlpath, *args, **kwargs)
2024-07-22 23:34:34.597 File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_store/http_client.py", line 166, in request
2024-07-22 23:34:34.597 raise errors.StoreServerError(response)
2024-07-22 23:34:34.597 craft_store.errors.StoreServerError: Store operation failed:
2024-07-22 23:34:34.597 - None: Items need to include 'library_id' or 'package_id'
2024-07-22 23:34:34.598 Full execution log: '/root/.local/state/charmcraft/log/charmcraft-20240722-233431.156756.log'
Traceback (most recent call last):
File "/snap/charmcraft/x1/bin/charmcraft", line 8, in <module>
sys.exit(main())
File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/application/main.py", line 160, in main
return app.run()
File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/application.py", line 538, in run
return_code = dispatcher.run() or 0
File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
return self._loaded_command.run(self._parsed_command_args)
File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/application/commands/store.py", line 1681, in run
libs_metadata = store.get_libraries_metadata_by_name(charm_libs)
File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/services/store.py", line 248, in get_libraries_metadata_by_name
for lib in self.get_libraries_metadata(libraries)
File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/services/store.py", line 240, in get_libraries_metadata
return self.anonymous_client.fetch_libraries_metadata(store_libs)
File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/store/client.py", line 103, in fetch_libraries_metadata
response = self.request_urlpath_json("POST", "/v1/charm/libraries/bulk", json=libs)
File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/store/client.py", line 64, in request_urlpath_json
response = self._http_client.request(method, self.api_base_url + urlpath, *args, **kwargs)
File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_store/http_client.py", line 166, in request
raise errors.StoreServerError(response)
craft_store.errors.StoreServerError: Store operation failed:
- None: Items need to include 'library_id' or 'package_id'
-----
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed misleading fetch-libs errors for unavailable libraries in merged PR #2034 (commit c9b51038), with a clearer missing-library message. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed in merged PR #2034 (commit c9b51038): fetch-libs now gives a clear error for unavailable libraries, lists declared charm-libs, and recommends checking names. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed in merged PR #2034 (commit c9b51038), giving fetch-libs a clear error when requested libraries do not exist. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed misleading fetch-libs errors for unavailable libraries in PR #2034 (commit c9b51038), providing a clearer error for nonexistent libraries. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed as a duplicate of #1721, which superseded #1754 as the tracking issue. No confirming fix commit or version was identified. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed and superseded by issue 1721. The fetch-libs error handling for unavailable libraries was marked as a duplicate, with tracking moved to Jira ticket CRAFT-3353. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by issue #1721. The fetch-libs error handling for unavailable libraries was marked as a duplicate and linked to Jira ticket CRAFT-3353. No direct fix was applied here. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as a duplicate. Maintainer linked to issue #1721, which addresses the same unclear fetch-libs error when libraries are unavailable. Resolved by consolidating reports. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed and superseded by issue #1721. The confusing fetch-libs error messages for unavailable libraries were linked to that upstream report, with internal ticket CRAFT-3353 created for tracking. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/charmcraft#2034
(confidence 100%)
Merged PR #2034 fixes the issue in commit c9b51038.
-
Duplicate Of:
canonical/charmcraft#1721
(confidence 85%)
The maintainer identified #1721 as likely the same bug; both reports were resolved by #2034.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1721 fetch-lib error is useless/misleading | charmcraft | closed | Fixed by merged PR #2084 (d0410f22), adding a clear fetch-lib error for unavailable libraries; the related fetch-libs case was fixed in #2034 (c9b51038). | |
| #1681 `fetch-libs` crashes with an internal error | charmcraft | closed | Fixed by merged PR #1701 (commit 3af2c248), which made fetch-libs handle library names containing underscores and resolved the crash. | |
| #2034 fix(store): nicer error message when getting nonexistent libs | charmcraft | merged | Merged PR #2034 (commit c9b51038), fixing #1754 by replacing Charmhub's unclear missing-library response with a clearer fetch-libs error. | |
| #1701 fix: make fetch-libs + underscores work | charmcraft | merged | Merged PR #1701 via commit 3af2c248, fixing fetch-libs handling of underscored library names and resolving #1681. | |
| #1702 fix: allow fetch-libs to work without logging in | charmcraft | merged | Merged PR #1702 as commit 1da46c8f, allowing fetch-libs to run without logging in and addressing #1681. |