From 2c22d1f044bc455ed2ff70f47c0f0a46f08fc4e1 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Thu, 3 Apr 2025 09:02:58 +0200 Subject: [PATCH] Fix 'osc fork' crash when there were no attributes defined in the OBS package --- osc/commands/fork.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osc/commands/fork.py b/osc/commands/fork.py index affa49b3..5823d00b 100644 --- a/osc/commands/fork.py +++ b/osc/commands/fork.py @@ -1,6 +1,7 @@ import re import sys import urllib.parse +from urllib.error import HTTPError import osc.commandline import osc.commandline_git @@ -77,7 +78,12 @@ class ForkCommand(osc.commandline.OscCommand): if not args.no_devel_project: # devel project is not set in package meta as usual but we parse it from "OBS:RejectBranch" attribute - attributes = obs_api.Attributes.from_api(args.apiurl, project, package, attr="OBS:RejectBranch").attribute_list + try: + attributes = obs_api.Attributes.from_api(args.apiurl, project, package, attr="OBS:RejectBranch").attribute_list + except HTTPError as e: + if e.code != 404: + raise + attributes = [] if attributes: attribute = attributes[0].value # the pattern starts with a non-greedy match so we capture the first url