mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-07 11:33:21 +08:00
catch errors at the root, remove unneccessary disabled rule
This commit is contained in:
@@ -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}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user