← Back to issue list

`charmcraft init` creates broken charm

View original Github issue

Metadata

Project
charmcraft
Number
#238
Type
issue
State
closed
Author
hatched
Labels
Created
Updated
Closed

Current evaluation

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.

Suggested action:

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
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.
qwen3.6-35b-a3b-mtp-q6 charmcraft init generated a charm with an unbound action event, causing deployment failures. The issue was superseded by PR 247, which overhauls the init workflow and tests to prevent such generation errors.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#243 Initial tests from `charmcraft init` do not pass charmcraft closed Superseded by PR #247, which updates the init workflow to resolve failing tests caused by invalid config.yaml generation.
82%
#91 First pass at 'charmcraft init' charmcraft merged Merged the initial 'charmcraft init' implementation. Approved by two reviewers, the PR adds 1087 lines across 24 files to scaffold charms. README.md, additional options, and interactive prompts require future updates.
77%
#142 fix the action generated by 'charmcraft init' charmcraft merged Merged a fix for the action generated by charmcraft init, resolving issue #141. Approved by three reviewers and verified by the reporter. Corrects a generation bug in the init command.
75%
#249 `charmcraft build` will let you build a charm that won't deploy charmcraft closed Closed and superseded by issue #27. The charmcraft build validation gap was consolidated into a tracking issue for implementing build-time sanity checks on config.yaml and actions.yaml.
73%
#328 charmcraft init produces error charm for machine charms charmcraft closed Closed without resolution. Maintainers acknowledged the core issue persists: charmcraft init still lacks a machine charm template or flag, leaving machine charm workflows unsupported despite claims that metadata changes fixed it.
70%