Skip to content

Commit 082980c

Browse files
adding more messages for pipeline in case of failure
Signed-off-by: Peter Arsenault <parsenau@progress.com>
1 parent dab27c6 commit 082980c

File tree

1 file changed

+53
-10
lines changed
  • .github/actions/chef-download-grype-snapshot

1 file changed

+53
-10
lines changed

.github/actions/chef-download-grype-snapshot/run.py

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,41 @@ def write_text(path, content):
7777
else:
7878
resolved_version = str(ver_doc)
7979
except RuntimeError as e:
80-
if "403" in str(e) or "401" in str(e):
81-
raise RuntimeError(
82-
f"Failed to fetch version from {ver_url.split('?')[0]} (status 403/401).\n"
83-
f"This may indicate:\n"
84-
f" 1. Missing or invalid license_id (both commercial and community sites require it)\n"
85-
f" 2. For 'community' site: requires a 'Free' license type, not a commercial license\n"
86-
f" 3. The product '{product}' or channel '{channel}' doesn't exist or isn't accessible\n"
87-
f"Solution: Provide appropriate LICENSE_ID for the download site type"
88-
) from e
80+
error_msg = str(e)
81+
if "403" in error_msg or "401" in error_msg or "Missing license_id" in error_msg or "License Id is not valid" in error_msg or "Only Free license" in error_msg:
82+
site_type = "commercial" if download_site == "commercial" else "community"
83+
license_secret = "GA_DOWNLOAD_GRYPE_LICENSE_ID" if download_site == "commercial" else "GA_DOWNLOAD_GRYPE_LICENSE_ID_FREE"
84+
85+
if "Missing license_id" in error_msg:
86+
raise RuntimeError(
87+
f"LICENSE ERROR ({site_type}): Missing license_id parameter.\n"
88+
f" Download site: {download_site}\n"
89+
f" Required secret: {license_secret}\n"
90+
f" Solution: Ensure the {license_secret} secret is set in the orchestrator repository"
91+
) from e
92+
elif "License Id is not valid" in error_msg or "403" in error_msg:
93+
raise RuntimeError(
94+
f"LICENSE ERROR ({site_type}): Invalid or expired license_id.\n"
95+
f" Download site: {download_site}\n"
96+
f" Product: {product}, Channel: {channel}\n"
97+
f" Secret used: {license_secret}\n"
98+
f" Solution: Update the {license_secret} secret with a valid {'commercial' if download_site == 'commercial' else 'Free'} license"
99+
) from e
100+
elif "Only Free license" in error_msg:
101+
raise RuntimeError(
102+
f"LICENSE ERROR (community): Wrong license type provided.\n"
103+
f" Download site: community\n"
104+
f" Error: Community downloads require a 'Free' license, but a commercial license was provided\n"
105+
f" Solution: Update GA_DOWNLOAD_GRYPE_LICENSE_ID_FREE secret with a valid Free license (not commercial)"
106+
) from e
107+
else:
108+
raise RuntimeError(
109+
f"LICENSE ERROR ({site_type}): Authentication failed.\n"
110+
f" Download site: {download_site}\n"
111+
f" Product: {product}, Channel: {channel}\n"
112+
f" Secret used: {license_secret}\n"
113+
f" Solution: Verify the {license_secret} secret contains a valid license for {download_site} downloads"
114+
) from e
89115
raise
90116

91117
# Construct download URL
@@ -104,7 +130,24 @@ def write_text(path, content):
104130

105131
# Download package
106132
pkg_path = os.path.join(work_dir, "package_downloaded.deb")
107-
run(["bash","-lc", f"curl -fsSL -o '{pkg_path}' '{download_url}'"], check=True)
133+
try:
134+
run(["bash","-lc", f"curl -fsSL -o '{pkg_path}' '{download_url}'"], check=True)
135+
except RuntimeError as e:
136+
if "403" in str(e) or "401" in str(e):
137+
site_type = "commercial" if download_site == "commercial" else "community"
138+
license_secret = "GA_DOWNLOAD_GRYPE_LICENSE_ID" if download_site == "commercial" else "GA_DOWNLOAD_GRYPE_LICENSE_ID_FREE"
139+
raise RuntimeError(
140+
f"DOWNLOAD ERROR ({site_type}): Failed to download package.\n"
141+
f" Product: {product} v{resolved_version}\n"
142+
f" Channel: {channel}, OS: {os_name} {os_ver}\n"
143+
f" Download site: {download_site}\n"
144+
f" This may indicate:\n"
145+
f" 1. Invalid or expired {license_secret} secret\n"
146+
f" 2. Package not available for this OS/version combination\n"
147+
f" 3. Version {resolved_version} doesn't exist in {channel} channel\n"
148+
f" Solution: Verify license and that the product/version/platform combination is valid"
149+
) from e
150+
raise
108151

109152
# Extract deterministically (pilot assumes Ubuntu .deb)
110153
extract_dir = os.path.join(work_dir, "extracted")

0 commit comments

Comments
 (0)