← Back to issue list

`name` field missing from packed charm's `metadata.yaml` when defined in `charmcraft.yaml` alongside a separate `metadata.yaml`

View original Github issue

Metadata

Project
charmcraft
Number
#2680
Type
issue
State
open
Author
javierdelapuente
Labels
Created
Updated
Closed

Current evaluation

Charmcraft 4.0.1 packs a metadata.yaml without the `name` field when `name` is defined in charmcraft.yaml and a separate metadata.yaml (lacking `name`) exists, making the charm undeployable in Juju. Confirmed by a second user; no maintainer response yet.

Suggested action: needs triage

Reason: No labels, no assignee, and no maintainer response — only a second user (@gfouillet) confirming the bug on 2026-05-05. The code path is visible: preprocess.add_metadata only migrates fields in METADATA_YAML_MIGRATE_FIELDS from metadata.yaml into charmcraft.yaml, and PackageService._write_file_or_object copies the source metadata.yaml verbatim when it exists, so a `name` defined only in charmcraft.yaml is never written into the packed metadata.yaml. This is a real, reproducible, app-breaking bug (Juju rejects the charm) affecting any project using the legacy split-file layout, so it needs triage and a fix rather than closure.

Impact: 80 Quick Win: 36.0 Staleness: 45 Complexity: 55 Confidence: 75 Support Request: 5

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description When a project has `name` in `charmcraft.yaml` and a separate `metadata.yaml` (without `name`), the packed `.charm` file contains a `metadata.yaml` with no `name` field. This makes the charm undeployable — Juju rejects it with `"metadata: name: expected string, got nothing"`. ### Steps to reproduce 1. Create a project with `name: my-charm` in `charmcraft.yaml` and a separate `metadata.yaml` that has `summary`, `description`, and relations but **no** `name` field. 2. Run `charmcraft pack --destructive-mode`. 3. Unzip the resulting `.charm` and inspect `metadata.yaml` — `name` is absent. 4. Attempt to deploy locally: `juju deploy ./my-charm_*.charm` → fails with `"metadata: name: expected string, got nothing"`. ### Environment charmcraft 4.0.1 (snap), destructive mode, Ubuntu 24.04 amd64. ### charmcraft.yaml ```yaml name: example-charm type: charm platforms: ubuntu@24.04:amd64: parts: charm: {} With a separate `metadata.yaml` containing `summary`, `description`, and relations but no `name`. ``` ### Log output ```shell juju.errors.JujuError: {"error":"cannot upload charm: invalid charm archive: metadata: name: expected string, got nothing","error-code":"bad request"} ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 80
Quick Win: 36.0
Staleness: 45
Complexity: 55
Confidence: 75
Support Request: 5
needs triage Charmcraft 4.0.1 packs a metadata.yaml without the `name` field when `name` is defined in charmcraft.yaml and a separate metadata.yaml (lacking `name`) exists, making the charm undeployable in Juju. Confirmed by a second user; no maintainer response yet.
qwen3.6-35b-a3b-mtp-q6
Staleness: 50
Complexity: 35
Confidence: 85
Support Request: 5
needs triage Packing a charm with a separate metadata.yaml omits the name field when defined only in charmcraft.yaml, breaking deployment. Unlabelled and awaiting maintainer triage.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 35
Confidence: 85
Support Request: 5
needs triage charmcraft pack omits the name field from metadata.yaml when name is defined in charmcraft.yaml but missing from a separate metadata.yaml, causing Juju deployment failures. Currently unlabelled and awaiting maintainer review.
qwen3.6-35b-moe-q4
Staleness: 45
Complexity: 40
Confidence: 90
Support Request: 5
needs triage Charmcraft pack omits the name field from the generated metadata.yaml when it is defined in charmcraft.yaml but missing from a separate metadata.yaml, causing Juju deployment failures. Currently unlabelled and awaiting maintainer triage.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 25
Confidence: 90
Support Request: 5
needs triage charmcraft 4.0 fails to merge the name field from charmcraft.yaml into a separate metadata.yaml during packing, producing undeployable charms. Confirmed by another user. Open, untriaged, last activity 41 days ago.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1530 Changing charmcraft.yaml doesn't update the resulting charm's metadata.yaml charmcraft open Bug: editing charmcraft.yaml then re-running `charmcraft pack` does not update the resulting charm's metadata.yaml. Filed by a maintainer (lengau); last comment (2024-09-09) says it's unclear if still reproducible. Related open craft-application#821 describes the same 'Already packed' skip behavior.
72%