canonical / charmcraft

Collaborate, build and publish charmed operators for Kubernetes, Linux and Windows.
Apache License 2.0
66 stars 71 forks source link

`fetch-libs` has weird error messages when libs aren't available #1754

Open lengau opened 3 months ago

lengau commented 3 months ago

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

The output of `charmcraft init --profile flask-framework`

Relevant log output

+ 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'
-----
lengau commented 1 month ago

Related to/probably the same bug as #1721

syncronize-issues-to-jira[bot] commented 1 month ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3353.

This message was autogenerated