fix(steps/actions): tolerate 204 No Content responses in _http
POST /api/v1/repos/{owner}/{repo}/actions/workflows/{file}/dispatches
returns HTTP 204 No Content on success (an empty body). The previous
implementation unconditionally called json.loads on the response,
which raised json.decoder.JSONDecodeError on the empty body. The
stack hit this with 'Expecting value: line 1 column 1 (char 0)' and
never advanced past GiteaActionsTrigger.
Return {} instead for empty / 204 responses so the trigger step
succeeds and the rest of the pipeline can run.
This commit is contained in:
@@ -59,7 +59,10 @@ class GiteaActionsTrigger(AbstractStep[GiteaActionsRun]):
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=30) as r:
|
||||
return json.loads(r.read().decode())
|
||||
body_bytes = r.read()
|
||||
if not body_bytes or r.status == 204:
|
||||
return {}
|
||||
return json.loads(body_bytes.decode())
|
||||
|
||||
def _list_recent_runs(self) -> Optional[GiteaActionsRun]:
|
||||
url = f"{self.api_base}/repos/{self.owner}/{self.repo}/actions/runs?limit=1"
|
||||
|
||||
Reference in New Issue
Block a user