Skip to content

Commit c81f2c4

Browse files
committed
fix: crash undefined deb/rpm main source
When the main archive is not defined (ie. not provided in build request and source not defined in YAML artifact definition file) on Deb or RPM package build, Fatbuildr now reports a task execution error instead of crashing. Fix #119
1 parent c3d81b7 commit c81f2c4

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
- Fix unusable version.dist variable in packaging code templates (#116).
4444
- Fix crash on build on unsupported derivative in instance pipelines (#117).
4545
- Fix crash on retrieving derivative version in artifact definition (#118).
46+
- Fix crash when main archive source is not defined on build of Deb or RPM
47+
package (#119).
4648

4749
## [2.0.0] - 2023-05-05
4850

fatbuildr/builds/formats/deb.py

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from .. import ArtifactEnvBuild
2525
from ...utils import current_user, extract_artifact_sources_archives
26+
from ...errors import FatbuildrTaskExecutionError
2627
from ...log import logr
2728

2829
logger = logr(__name__)
@@ -98,6 +99,12 @@ def _build_src(self):
9899
self.artifact,
99100
)
100101

102+
if self.main_archive is None:
103+
raise FatbuildrTaskExecutionError(
104+
f"Main archive of deb package artifact {self.artifact} is not "
105+
"defined"
106+
)
107+
101108
# Deb source packages do not support source archives in zip format, then
102109
# first convert all source archives in zip format to tarballs.
103110
for archive in self.archives:

fatbuildr/builds/formats/rpm.py

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from ...registry.formats import ChangelogEntry
2424
from ...templates import Templeter
2525
from ...utils import current_user, current_group
26+
from ...errors import FatbuildrTaskExecutionError
2627
from ...log import logr
2728

2829
logger = logr(__name__)
@@ -166,6 +167,12 @@ def _build_src(self):
166167
self.native_env,
167168
)
168169

170+
if self.main_archive is None:
171+
raise FatbuildrTaskExecutionError(
172+
f"Main archive of rpm package artifact {self.artifact} is not "
173+
"defined"
174+
)
175+
169176
# Initialize templater
170177
templater = Templeter()
171178

fatbuildr/errors.py

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class FatbuildrRuntimeError(Exception):
2222
pass
2323

2424

25+
class FatbuildrTaskExecutionError(FatbuildrRuntimeError):
26+
pass
27+
28+
2529
class FatbuildrServerError(Exception):
2630
pass
2731

fatbuildr/tasks/manager.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import shutil
2424
from collections import deque
2525

26+
from ..errors import FatbuildrTaskExecutionError
2627
from ..log import logr
2728
from ..protocols.exports import ProtocolRegistry
2829

@@ -175,7 +176,7 @@ def run(self, task):
175176
task.prerun()
176177
try:
177178
task.run()
178-
except RuntimeError as err:
179+
except (FatbuildrTaskExecutionError, RuntimeError) as err:
179180
logger.error("error while running task %s: %s", task.id, err)
180181
logger.info("Task failed")
181182
else:

0 commit comments

Comments
 (0)