catch errors at the root, remove unneccessary disabled rule

This commit is contained in:
Bethany
2023-08-09 12:08:43 -07:00
parent e8fb71c4bb
commit b851b70474
4 changed files with 29 additions and 68 deletions

View File

@@ -56,8 +56,6 @@ class ArtifactHttpClient implements Rpc {
const headers = {
'Content-Type': contentType
}
info(`Making request to ${url} with data: ${JSON.stringify(data)}`)
try {
const response = await this.retryableRequest(async () =>
this.httpClient.post(url, JSON.stringify(data), headers)
@@ -65,7 +63,7 @@ class ArtifactHttpClient implements Rpc {
const body = await response.readBody()
return JSON.parse(body)
} catch (error) {
throw new Error(error.message)
throw new Error(`Failed to ${method}: ${error.message}`)
}
}

View File

@@ -11,13 +11,15 @@ interface ActionsToken {
scp: string
}
const InvalidJwtError = new Error('Failed to get backend IDs: The provided JWT token is invalid')
// uses the JWT token claims to get the
// workflow run and workflow job run backend ids
export function getBackendIdsFromToken(): BackendIds {
const token = getRuntimeToken()
const decoded = jwt_decode<ActionsToken>(token)
if (!decoded.scp) {
throw new Error('No scp claim in JWT token')
throw InvalidJwtError
}
/*
@@ -29,7 +31,7 @@ export function getBackendIdsFromToken(): BackendIds {
const scpParts = decoded.scp.split(' ')
if (scpParts.length === 0) {
throw new Error('No scp parts in JWT token')
throw InvalidJwtError
}
/*
* example scpParts:
@@ -58,7 +60,7 @@ export function getBackendIdsFromToken(): BackendIds {
}
}
throw new Error('No valid Actions.Results scope in JWT token')
throw InvalidJwtError
}
export function getExpiration(retentionDays?: number): Timestamp | undefined {