Skip to content

Commit

Permalink
Add nonexistent service account key check to GCP app
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhanunlu committed Jan 10, 2025
1 parent eab00a5 commit 4195ae1
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package com.snowplowanalytics.snowplow.lakes

import cats.implicits._

import com.google.api.client.auth.oauth2.TokenResponseException
import com.google.api.client.googleapis.json.GoogleJsonResponseException

import com.snowplowanalytics.snowplow.sources.pubsub.{PubsubSource, PubsubSourceConfig}
Expand All @@ -24,12 +25,15 @@ object GcpApp extends LoaderApp[PubsubSourceConfig, PubsubSinkConfig](BuildInfo)
override def badSink: SinkProvider = PubsubSink.resource(_)

override def isDestinationSetupError: DestinationSetupErrorCheck = {
// Destination bucket doesn't exist
case e: GoogleJsonResponseException if e.getDetails.getCode === 404 =>
"The specified bucket does not exist"
// Permissions missing for Cloud Storage
case e: GoogleJsonResponseException if e.getDetails.getCode === 403 =>
// Bad Request - Key belongs to nonexistent service account
case e: TokenResponseException if e.getStatusCode === 400 =>
e.getMessage
// Forbidden - Permissions missing for Cloud Storage
case e: GoogleJsonResponseException if Option(e.getDetails).map(_.getCode).contains(403) =>
e.getDetails.getMessage
// Not Found - Destination bucket doesn't exist
case e: GoogleJsonResponseException if Option(e.getDetails).map(_.getCode).contains(404) =>
"The specified bucket does not exist"
// Exceptions common to the table format - Delta/Iceberg/Hudi
case TableFormatSetupError.check(t) =>
t
Expand Down

0 comments on commit 4195ae1

Please sign in to comment.