fix: handle disabled/destroyed values in gcp sync

This commit is contained in:
Scott Wilson
2025-03-14 11:04:49 -07:00
parent 5ebf142e3e
commit fd1afc2cbe

View File

@@ -71,8 +71,13 @@ const getGcpSecrets = async (accessToken: string, secretSync: TGcpSyncWithCreden
res[key] = Buffer.from(secretLatest.payload.data, "base64").toString("utf-8");
} catch (error) {
// when a secret in GCP has no versions, we treat it as if it's a blank value
if (error instanceof AxiosError && error.response?.status === 404) {
// when a secret in GCP has no versions, or is disabled/destroyed, we treat it as if it's a blank value
if (
error instanceof AxiosError &&
(error.response?.status === 404 ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(error.response?.status === 400 && error.response.data.error.status === "FAILED_PRECONDITION"))
) {
res[key] = "";
} else {
throw new SecretSyncError({