Skip to content

Commit

Permalink
fix(Beaker): rerurn common dictionary when validation fails
Browse files Browse the repository at this point in the history
when Beaker distro/image is not recognized by beakerhub
mrack failed with exception as newer code expects
dictionary error object.

Signed-off-by: Tibor Dudlák <[email protected]>
  • Loading branch information
Tiboris committed Feb 22, 2023
1 parent b6c5ef4 commit fd33d68
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mrack/providers/beaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@


def parse_bkr_exc_str(exc_str):
"""Parse exception string and return more readable string for mrack error."""
"""Parse exception string and return response dictionary for mrack error."""
# we expect exception string to look like following:
# '<class \'bkr.common.bexceptions.BX\'>:No distro tree matches Recipe:
# <distroRequires>
Expand All @@ -60,7 +60,7 @@ def parse_bkr_exc_str(exc_str):
and "bkr.common.bexceptions" not in exc_str.faultString
):
# we got string we do not expect so just use the traceback
return str(exc_str)
return {"response": str(exc_str)}

# because of expected format we split by ":" and use last 2 values from list
# in above example it would be
Expand All @@ -69,7 +69,7 @@ def parse_bkr_exc_str(exc_str):
# '\t<distroRequires><and><distro_name op="like" value="Fedora-33%"/> ...
# ]
fault = [f"\t{f.strip()}" for f in exc_str.faultString.split(":")[-2:]]
return "\n".join(fault)
return {"response": "\n".join(fault)}


class BeakerProvider(Provider):
Expand Down

0 comments on commit fd33d68

Please sign in to comment.