plugin handler: properly handle snapcraftctl errors
Metadata
Current evaluation
Merged fix for plugin handler to properly catch snapcraftctl errors. Replaced specific exception handling with a broad catch in the scriptlet runner to prevent silent failures and redundant output. Approved, passed CI, and increased coverage.
Suggested action: —
No scores available.
Issue body
Address issues including:
- snapcraftctl operations always exiting with 0, even for failure
cases.
- snapcraft override scripts continue to run even after
parent snapcraft process fails. This is because `set -e` does
not catch the error when snapcraftctl returns 0, and nothing
is otherwise done to terminate the script.
Given the nature of these symptoms, this is likely the cause of
a number of other seemingly unrelated issues.
These issues occur because _handle_builtin_function() only
catches exceptions of type errors.ScriptletBaseError,
ignoring other cases that may result from the build/pull operations,
such as NodejsPluginMissingPackageJsonError, or
SnapcraftPluginBuildError.
Instead of trying to manage exceptions in _handle_builtin_function(),
catch _any_ unhandled exception in _run_scriplet()'s try block. This
simplifies the more complex return value and feedback handling.
Don't print an error from the feedback channel in snapcraftctl,
the parent process will take care of it. This is necessary
because the error that is now seen by snapcraftctl would lead
to redundant output. Just exit with -1 when an error is
read from the feedback fifo.
LP: #1898922
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged fix for plugin handler to properly catch snapcraftctl errors. Replaced specific exception handling with a broad catch in the scriptlet runner to prevent silent failures and redundant output. Approved, passed CI, and increased coverage. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged into master. Fixes snapcraftctl error handling in plugin handlers to properly exit on failures and halt override scripts. Updates _run_scriplet() to catch unhandled exceptions and exit with -1, resolving LP #1898922. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged into master. Resolves LP #1898922 by catching all unhandled exceptions in _run_scriplet, ensuring snapcraftctl properly propagates errors and prevents redundant output. Increases coverage by 0.02%. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2251 pluginhandler: stop using alias for snapcraftctl | snapcraft | merged | Merged. Replaced snapcraftctl alias usage with direct PATH installation in the pluginhandler. This prepares the codebase for subshell scriptlet execution, where aliases fail. Approved by reviewers and passed all CI checks. | |
| #3139 pluginhandler: run plugin commands in isolation | snapcraft | merged | Merged updates to execute plugin commands in isolation, enhancing error reporting and matching PluginV1 behavior. Resolves SNAPCRAFT-1NQ following successful review and CI validation. | |
| #2337 pluginhandler: library detection instead of injection | snapcraft | merged | Merged. Replaced host binary injection with library detection via base snaps, converting missing library errors to warnings. Approved by reviewer and passed CI checks. | |
| #2117 pluginhandler: correctly dedent the run script | snapcraft | merged | Merged fix to correctly dedent the pluginhandler run script. Passes CI checks and serves as prework for improved error output, partially addressing Launchpad bug #1767625. | |
| #3406 pluginhandler: do not walk symlinks for include filesets | snapcraft | merged | Merged fix prevents snapcraft from incorrectly traversing symlinks during include fileset generation. Checks targets before walking to resolve filtering issues for symlinked directories. Approved, passed CI, and merged. | |
| #2454 baseplugin: add a proper exception for cross-compilation support | snapcraft | merged | Merged changes add a proper exception to notify users when cross-compilation is used with unsupported plugins. Approved, passed CI, and achieved 100% diff coverage. Resolves SNAPCRAFT-95, SNAPCRAFT-AQ, and LP: #1808454. | |
| #228 packages: run snap operations silently | craft-parts | merged | Merged to fix #218 by running snap subprocesses silently, preventing stdout leakage that conflicts with craft-cli during lifecycle execution. Approved by one reviewer, passed CI, and modified two files (+32/-15 lines). | |
| #3211 pluginhandler: fix stage-snaps for v2 plugins | snapcraft | merged | Merged fix for v2 plugin AttributeError caused by missing stage_snaps attribute. Updated logging to use part_install_dir and resolved prepare_build clearing the install directory. Approved and passed CI. | |
| #499 fix(config): wrap snap config handler in snap check | craft-application | merged | Merged a fix wrapping the snap config handler in a snap environment check to prevent execution errors outside snaps. Approved by two reviewers, passed CI, and introduced 12 lines across two files. | |
| #2021 pluginhandler: only resort to elf mangling if the snap type is app | snapcraft | merged | Merged a fix restricting ELF mangling to app-type snaps only. Approved, passed CI, and updated one file with 12 additions and 4 deletions. |