You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes it impossible to react to different kinds of failures when calling sendBatch. In my case, I want to remove invalid device tokens from my database.
) instead of the standard error the issue would be resolved.
Relevant Code:
func (firebaseSender*FirebaseSender) cleanupDevices(ctx context.Context, batchResponse*messaging.BatchResponse) {
ifbatchResponse.FailureCount==0 {
return
}
for_, sendResponse:=rangebatchResponse.Responses {
logger.Debug(sendResponse.Error) // Expose ErrorCode here so that I can switch and deal with different kinds of failures.
}
}
The internal library has the data structure I need, but it is in the internal library and unavailable to other modules.
// ErrorCode represents the platform-wide error codes that can be raised by// Admin SDK APIs.typeErrorCodestringconst (
// InvalidArgument is a OnePlatform error code.InvalidArgumentErrorCode="INVALID_ARGUMENT"// FailedPrecondition is a OnePlatform error code.FailedPreconditionErrorCode="FAILED_PRECONDITION"// OutOfRange is a OnePlatform error code.OutOfRangeErrorCode="OUT_OF_RANGE"// Unauthenticated is a OnePlatform error code.UnauthenticatedErrorCode="UNAUTHENTICATED"// PermissionDenied is a OnePlatform error code.PermissionDeniedErrorCode="PERMISSION_DENIED"// NotFound is a OnePlatform error code.NotFoundErrorCode="NOT_FOUND"// Conflict is a custom error code that represents HTTP 409 responses.//// OnePlatform APIs typically respond with ABORTED or ALREADY_EXISTS explicitly. But a few// old APIs send HTTP 409 Conflict without any additional details to distinguish between the two// cases. For these we currently use this error code. As more APIs adopt OnePlatform conventions// this will become less important.ConflictErrorCode="CONFLICT"// Aborted is a OnePlatform error code.AbortedErrorCode="ABORTED"// AlreadyExists is a OnePlatform error code.AlreadyExistsErrorCode="ALREADY_EXISTS"// ResourceExhausted is a OnePlatform error code.ResourceExhaustedErrorCode="RESOURCE_EXHAUSTED"// Cancelled is a OnePlatform error code.CancelledErrorCode="CANCELLED"// DataLoss is a OnePlatform error code.DataLossErrorCode="DATA_LOSS"// Unknown is a OnePlatform error code.UnknownErrorCode="UNKNOWN"// Internal is a OnePlatform error code.InternalErrorCode="INTERNAL"// Unavailable is a OnePlatform error code.UnavailableErrorCode="UNAVAILABLE"// DeadlineExceeded is a OnePlatform error code.DeadlineExceededErrorCode="DEADLINE_EXCEEDED"
)
// FirebaseError is an error type containing an error code string.typeFirebaseErrorstruct {
ErrorCodeErrorCodeStringstringResponse*http.ResponseExtmap[string]interface{}
}
func (fe*FirebaseError) Error() string {
returnfe.String
}
The text was updated successfully, but these errors were encountered:
I'm using Firebase Auth, when it fails to verify a token, Im able to know the reason from the message, however, because the ErrorCode and Ext fields are not exposed, I'm not able to handle each case programmaticlly.
So yep, it will be really helpful to expose the fields and error codes, please add the feature, thank you!
I also have troubles with the FirebaseError being in an internal package, since there is no way to use it in e.g. errors.Is or errors.As (the idiomatic way to compare errors) as well as to create such an error on my own (e.g. in a mock used in unit tests), which makes it unnecessarily hard to test code using this module for interactions with Firebase. Since the FirebaseError is returned from the methods provided by this module, I consider it as part of the API and therefore it should be exposed.
The errorutils package is somewhat helpful, but to me, it looks more like a workaround.
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
The messaging api returns robust error codes to tell your application what went wrong with the server. This go-lang library abstracts this away and only gives you the following struct: https://github.com/firebase/firebase-admin-go/blob/v4.12.0/messaging/messaging_batch.go#L78
This makes it impossible to react to different kinds of failures when calling
sendBatch
. In my case, I want to remove invalid device tokens from my database.If the lib could return this struct (
firebase-admin-go/internal/errors.go
Line 87 in 74c9bd5
Relevant Code:
The internal library has the data structure I need, but it is in the internal library and unavailable to other modules.
The text was updated successfully, but these errors were encountered: