`charmcraft init` creates broken charm
Metadata
Current evaluation
Superseded by charmcraft#247, a planned overhaul of init templates and generated tests; #247 later closed without implementing its proposed guard against building incomplete templates.
Resolution: closed superseded
Reason: A maintainer redirected the report to charmcraft#247, which proposed improving `charmcraft init` and its tests. No merged fix was cited, and #247 later closed without implementing the proposed build guard.
Evaluated by: mr-cal-bot
No scores available.
Issue body
It looks like the install hook expects an action to exist?
To reproduce:
- run `charmcraft init`
- change the series in `metadata.yaml` to `focal`
- `charmcraft build`
- deploy the charm
```
juju-dashboard-charm-0: 16:21:17 INFO juju.worker.uniter awaiting error resolution for "install" hook
juju-dashboard-charm-0: 16:21:17 INFO unit.juju-dashboard-charm/0.juju-log Running legacy hooks/install.
juju-dashboard-charm-0: 16:21:17 ERROR unit.juju-dashboard-charm/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
File "./src/charm.py", line 46, in <module>
main(JujuDashboardCharmCharm)
File "/var/lib/juju/agents/juju-dashboard-charm-0/charm/venv/ops/main.py", line 390, in main
charm = charm_class(framework)
File "./src/charm.py", line 24, in __init__
self.framework.observe(self.on.fortune_action, self._on_fortune_action)
AttributeError: 'CharmEvents' object has no attribute 'fortune_action'
juju-dashboard-charm-0: 16:21:17 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1
juju-dashboard-charm-0: 16:21:17 INFO juju.worker.uniter awaiting error resolution for "install" hook
juju-dashboard-charm-0: 16:22:36 INFO juju.worker.uniter awaiting error resolution for "install" hook
juju-dashboard-charm-0: 16:22:36 INFO unit.juju-dashboard-charm/0.juju-log Running legacy hooks/install.
juju-dashboard-charm-0: 16:22:36 ERROR unit.juju-dashboard-charm/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
File "./src/charm.py", line 46, in <module>
main(JujuDashboardCharmCharm)
File "/var/lib/juju/agents/juju-dashboard-charm-0/charm/venv/ops/main.py", line 390, in main
charm = charm_class(framework)
File "./src/charm.py", line 24, in __init__
self.framework.observe(self.on.fortune_action, self._on_fortune_action)
AttributeError: 'CharmEvents' object has no attribute 'fortune_action'
juju-dashboard-charm-0: 16:22:37 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1
juju-dashboard-charm-0: 16:22:37 INFO juju.worker.uniter awaiting error resolution for "install" hook
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed superseded | Superseded by charmcraft#247, a planned overhaul of init templates and generated tests; #247 later closed without implementing its proposed guard against building incomplete templates. | |
| stealth/space-bunny-alpha | — | closed superseded | Superseded by canonical/charmcraft#247, a planned overhaul of charmcraft init and its tests; the redesign later closed without implementing its proposed build guard. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by PR #247, which overhauls charmcraft init and its tests to prevent broken charm generation from commented-out actions. The new implementation resolves the template and test failures. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by PR 247, which overhauled the charmcraft init template and tests to fix broken action hook references and ensure generated charms work out of the box. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed and superseded by PR #247, which overhauled charmcraft init and its tests to prevent generating broken charm code with missing action definitions. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed as superseded by PR #247, which overhauls the init command and tests to prevent generated charms from failing when actions are commented out. |
Update history
No update history recorded yet.
Related work
-
Superseded By:
canonical/charmcraft#247
(confidence 98%)
Maintainer identified this overhaul of `init` and generated tests as the follow-up intended to improve the situation.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #243 Initial tests from `charmcraft init` do not pass | charmcraft | closed | Superseded by charmcraft#247, which took ownership of redesigning charmcraft init and its generated tests; no direct fixing implementation was recorded for #243. | |
| #91 First pass at 'charmcraft init' | charmcraft | merged | Merged PR #91 delivered the first non-interactive charmcraft init scaffolding implementation; README improvements, extra options, and prompts were deferred (commit 0ebd9f87). | |
| #328 charmcraft init produces error charm for machine charms | charmcraft | closed | Machine charms gained a dedicated charmcraft init profile, resolving Kubernetes-only initialization; the change was merged in PR #868 (commit 2ed9033c). | |
| #249 `charmcraft build` will let you build a charm that won't deploy | charmcraft | closed | Closed by facundobatista as a duplicate, tracking all build-time sanity checks (incl. config.yaml/actions.yaml validity) in the umbrella issue charmcraft#27; later implemented by merged PR #556 (a585aec6). | |
| #1149 command: charmcraft init to use charmcraft.yaml only | charmcraft | merged | Merged in ca4df024: charmcraft init now generates a unified charmcraft.yaml containing metadata, actions, and config, with profile descriptions and an updated URL. | |
| #452 build: create charm builder tool (CRAFT-373) | charmcraft | closed | Superseded by merged charmcraft#453, which moved charm-building logic to a standalone CharmBuilder; the venv and pip optimizations were deferred. | |
| #762 Dynamically import charmcraft init template | charmcraft | closed | Closed in favor of broader charmcraft init profile work, notably #568; live template-repository fetching was left for future discussion. Profile support later landed through PRs #854, #859 and #868. | |
| #32 The charm tool should offer an initial skeleton | charmcraft | closed | Implemented `charmcraft init` to generate an initial charm skeleton via merged PR canonical/charmcraft#91. | |
| #197 `charmcraft init` should not populate actions.yaml with real data | charmcraft | closed | charmcraft#197 was closed as abandoned after years of inactivity, with no recorded resolving PR or commit. | |
| #568 Add a `charmcraft init` template for machine charms | charmcraft | closed | The machine-charm init-template request was closed without a linked fix after the March 2022 discussion; later profile work is not tied to its closure. |