Skip to content

Commit f0c28a1

Browse files
authored
Use Base64.NO_WRAP to avoid unexpected char errors in Apollo (#2745)
1 parent 9dddfbf commit f0c28a1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
### Fixes
1717

18+
- Use Base64.NO_WRAP to avoid unexpected char errors in Apollo ([#2745](https://github.com/getsentry/sentry-java/pull/2745))
1819
- Don't warn R8 on missing `ComposeViewHierarchyExporter` class ([#2743](https://github.com/getsentry/sentry-java/pull/2743))
1920

2021
## 6.20.0

sentry-apollo-3/src/main/java/io/sentry/apollo3/SentryApollo3HttpInterceptor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class SentryApollo3HttpInterceptor @JvmOverloads constructor(private val hub: IH
125125
private fun decodeHeaderValue(request: HttpRequest, headerName: String): String? {
126126
return request.valueForHeader(headerName)?.let {
127127
try {
128-
String(Base64.decode(it, Base64.DEFAULT))
128+
String(Base64.decode(it, Base64.NO_WRAP))
129129
} catch (e: IllegalArgumentException) {
130130
hub.options.logger.log(SentryLevel.ERROR, "Error decoding internal apolloHeader $headerName", e)
131131
return null

sentry-apollo-3/src/main/java/io/sentry/apollo3/SentryApollo3Interceptor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class SentryApollo3Interceptor : ApolloInterceptor {
2323
chain: ApolloInterceptorChain
2424
): Flow<ApolloResponse<D>> {
2525
val builder = request.newBuilder()
26-
.addHttpHeader(SENTRY_APOLLO_3_OPERATION_TYPE, Base64.encodeToString(operationType(request).toByteArray(), Base64.DEFAULT))
27-
.addHttpHeader(SENTRY_APOLLO_3_OPERATION_NAME, Base64.encodeToString(request.operation.name().toByteArray(), Base64.DEFAULT))
26+
.addHttpHeader(SENTRY_APOLLO_3_OPERATION_TYPE, Base64.encodeToString(operationType(request).toByteArray(), Base64.NO_WRAP))
27+
.addHttpHeader(SENTRY_APOLLO_3_OPERATION_NAME, Base64.encodeToString(request.operation.name().toByteArray(), Base64.NO_WRAP))
2828

2929
request.scalarAdapters?.let {
30-
builder.addHttpHeader(SENTRY_APOLLO_3_VARIABLES, Base64.encodeToString(request.operation.variables(it).valueMap.toString().toByteArray(), Base64.DEFAULT))
30+
builder.addHttpHeader(SENTRY_APOLLO_3_VARIABLES, Base64.encodeToString(request.operation.variables(it).valueMap.toString().toByteArray(), Base64.NO_WRAP))
3131
}
3232
return chain.proceed(builder.build())
3333
}

0 commit comments

Comments
 (0)