canonical / canonical/craft-cli
CraftError messages with new lines render inconsistently
- Dominant language
- Python
- Stars
- 16
- Forks
- 27
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 10
Description
### Bug Description
If the `message` field in a `CraftError` contains a new line, craft-cli appears to append whitespace, which causes the appearance of a new line between the `message` and `resolution` sections.
Note that I cannot use the `details` field because `details` isn't visible at the default `brief` verbosity level.
### To Reproduce
```diff
diff --git a/examples.py b/examples.py
index c842a1a..c7fe76e 100755
--- a/examples.py
+++ b/examples.py
def example_10():
@@ -513,6 +516,15 @@ def example_30():
time.sleep(0.001)
+def example_31():
+ """Show an error."""
+ path = "/dev/null"
+ raise CraftError(
+ message="Remote build does not support building multiple snaps on the same architecture:\n - Building on 'amd64' will create snaps for 'amd64' and 'riscv64'.",
+ resolution="this is the resolution",
+ )
+
+
# -- end of test cases
if len(sys.argv) < 2:
```
### part yaml
_No response_
### Relevant log output
See the attached pictures. The same photo is highlighted to show what appears to be extraneous whitespace.


Contributor guide
Research direction
Reproduce the behavior using example_31 in examples.py and inspect how CraftError renders its message and resolution at the default brief verbosity. Done means a message containing a newline no longer produces inconsistent or extraneous whitespace before the resolution section.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100