Unable to release charm to charmhub with optional resource

I’m unable to release my nextcloud charm due to missing resource.

Here is the repo: GitHub - nextcloud-charmers/operator-nextcloud: Nextcloud Juju operator

I can deploy and run it perfectly locally.

But, charmhub won’t let me release it.

charmcraft upload  nextcloud_ubuntu@22.04-amd64.charm
Revision 37 of 'nextcloud' created
charmcraft upload  nextcloud_ubuntu@24.04-amd64.charm
Revision 38 of 'nextcloud' created

Upload works

Relase doesnt.

charmcraft release nextcloud -r 37 -c edge
Store operation failed:
- api-error: Resource 'nextcloud-tarfile' missing from this 'nextcloud' release or any previously released revisions on channel: edge
Full execution log: '/home/erik/.local/state/charmcraft/log/charmcraft-20250212-023632.702970.log'
erik@frozen:~/operator-nextcloud$ cat /home/erik/.local/state/charmcraft/log/charmcraft-20250212-023632.702970.log'
> ^C
erik@frozen:~/operator-nextcloud$ cat /home/erik/.local/state/charmcraft/log/charmcraft-20250212-023632.702970.log
2025-02-12 02:36:32.703 Starting charmcraft, version 3.4.2
2025-02-12 02:36:32.703 Log verbosity level set to BRIEF
2025-02-12 02:36:32.703 Preparing application...
2025-02-12 02:36:32.703 Configuring application...
2025-02-12 02:36:32.705 Setting up ConfigService
2025-02-12 02:36:32.716 Build plan: platform=None, build_for=None
2025-02-12 02:36:32.716 Running charmcraft release on host
2025-02-12 02:36:32.782 Retrieving credentials for 'charmcraft' on 'api.charmhub.io' from keyring 'SecretService Keyring'.
2025-02-12 02:36:32.805 HTTP 'POST' for 'https://api.charmhub.io/v1/charm/nextcloud/releases' with params None and headers {'Authorization': '<macaroon>', 'User-Agent': 'charmcraft/3.4.2 ubuntu/22.04 (x86_64) python/3.10.12'}
2025-02-12 02:36:33.257 Store operation failed:
2025-02-12 02:36:33.258 - api-error: Resource 'nextcloud-tarfile' missing from this 'nextcloud' release or any previously released revisions on channel: edge
2025-02-12 02:36:33.258 Traceback (most recent call last):
2025-02-12 02:36:33.258   File "/snap/charmcraft/5977/lib/python3.10/site-packages/charmcraft/store/store.py", line 141, in error_decorator
2025-02-12 02:36:33.259     return method(self, *args, **kwargs)
2025-02-12 02:36:33.259   File "/snap/charmcraft/5977/lib/python3.10/site-packages/charmcraft/store/store.py", line 387, in release
2025-02-12 02:36:33.259     return self._client.request_urlpath_json("POST", endpoint, json=items)
2025-02-12 02:36:33.259   File "/snap/charmcraft/5977/lib/python3.10/site-packages/charmcraft/store/client.py", line 197, in request_urlpath_json
2025-02-12 02:36:33.259     response = super().request(method, self.api_base_url + urlpath, *args, **kwargs)
2025-02-12 02:36:33.259   File "/snap/charmcraft/5977/lib/python3.10/site-packages/craft_store/base_client.py", line 189, in request
2025-02-12 02:36:33.259     return self.http_client.request(
2025-02-12 02:36:33.259   File "/snap/charmcraft/5977/lib/python3.10/site-packages/craft_store/http_client.py", line 165, in request
2025-02-12 02:36:33.259     raise errors.StoreServerError(response)
2025-02-12 02:36:33.259 craft_store.errors.StoreServerError: Store operation failed:
2025-02-12 02:36:33.259 - api-error: Resource 'nextcloud-tarfile' missing from this 'nextcloud' release or any previously released revisions on channel: edge
2025-02-12 02:36:33.259 Full execution log: '/home/erik/.local/state/charmcraft/log/charmcraft-20250212-023632.702970.log'

I have never needed to supply a resource before. It was some years ago I think it was needed to supply an “empty” resource. Is this back?

What should I do to get my nextcloud charm back on track?

Resources aren’t packed into the charm so they don’t get uploaded when you upload the charm – they must be uploaded separately. See https://canonical-charmcraft.readthedocs-hosted.com/en/latest/howto/manage-charms/#publish-a-charm-on-charmhub and especially https://canonical-charmcraft.readthedocs-hosted.com/en/latest/howto/manage-resources/#publish-a-resource-on-charmhub

1 Like

Totally, but its strange, since I’ve never needed to do this before as far as I know - or - it might just have been something happening in the background.

My charm uses the resources as an optional resource so it might be difficult to test the behavior of a deployment if charmhub somehow decides to include it when deploying from charmhub rather than from local.

My local deploy happily works without a resource…

Ha. @lengau any idea what’s going on?

Hi! So as far as I understand (maybe @bowenfan, @superalpaca, @maxiberta or someone else on the store team can interject), in order to be published to a channel, a charm revision must be matched to every resource it links, even if that resource is optional. I don’t know if there’s a way in the store to get around that.

I’m fumbling in the dark.

  • I uploaded a resource
  • I’m trying to release
  • … error

Using this documentation: https://canonical-charmcraft.readthedocs-hosted.com/en/latest/howto/manage-resources/#publish-a-resource-on-charmhub

I tried again to upload, a few times with peculiar behaviour with an empty resource, as you can see in the image below:

I desperately added a “1” to the resource, at which point it updated the resource to revision 2.

But, it still wont let me release the nextcloud charm to the revision 38 which is what I want.

If someone could show a complete guide to make this work, it would be great.

Sorry I didn’t see this before your (excellent, BTW!) workshop began!

What you’ll need to run in this case is:

charmcraft release nextcloud -r 38 -c edge --resource nextcloud-tarfile:1

That attaches revision 1 of the nextcloud-tarfile resource to that release (and it’ll automatically use it for future releases to that channel).

2 Likes

@erik-lonroth just tried it and it worked. Thanks, @lengau ! (And I really should have remembered this as well :confused: Though I see it’s not in the docs either: https://canonical-charmcraft.readthedocs-hosted.com/en/latest/howto/manage-charms/#publish-a-charm-on-charmhub We should update step 5 there with an example release for a charm with a resource.)

Agreed! "Publish a charm to Charmhub" should include an example with your first resource. · Issue #2171 · canonical/charmcraft · GitHub

Just put up a PR to fix the issue: docs: update release step with resource details by tmihoc · Pull Request #2172 · canonical/charmcraft · GitHub Thanks to @erik-lonroth for providing the example output.

Totally works.

1 Like