Skip to content

Commit c799f3d

Browse files
committed
fix(bugsnag): filter "payment is a no-op" InvalidIntent from reporting
Mark SubmitIntentError.InvalidIntent as ConditionallyNotifiable so "payment is a no-op" reasons are treated as expected and suppressed from Bugsnag, matching the StaleState pattern.
1 parent 7236f31 commit c799f3d

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

services/opencode/src/main/kotlin/com/getcode/opencode/model/core/errors/Errors.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,16 @@ sealed class SubmitIntentError(
115115
override val cause: Throwable? = null
116116
) : CodeServerError(message, cause) {
117117
data class InvalidIntent(private val reasons: List<String>) :
118-
SubmitIntentError(message = reasons.joinToString()), NotifiableError
118+
SubmitIntentError(message = reasons.joinToString()), ConditionallyNotifiable {
119+
val isPaymentNoOp: Boolean
120+
get() = reasons.any { it.contains("payment is a no-op") }
121+
122+
val isExpected: Boolean
123+
get() = isPaymentNoOp
124+
125+
override val isNotifiable: Boolean
126+
get() = !isExpected
127+
}
119128

120129
data class Signature(private val details: List<String> = emptyList()) :
121130
SubmitIntentError(message = buildString {

services/opencode/src/test/kotlin/com/getcode/opencode/model/core/errors/SubmitIntentErrorTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ class SubmitIntentErrorTest {
239239
assertFalse(error.isAccountAlreadyOpened)
240240
}
241241

242+
@Test
243+
fun invalidIntentWithPaymentNoOpIsNotNotifiable() {
244+
val error = SubmitIntentError.InvalidIntent(listOf("payment is a no-op"))
245+
assertTrue(error.isPaymentNoOp)
246+
assertTrue(error.isExpected)
247+
assertFalse(error.isNotifiable)
248+
}
249+
250+
@Test
251+
fun invalidIntentWithOtherReasonIsNotifiable() {
252+
val error = SubmitIntentError.InvalidIntent(listOf("bad amount"))
253+
assertFalse(error.isPaymentNoOp)
254+
assertFalse(error.isExpected)
255+
assertTrue(error.isNotifiable)
256+
}
257+
242258
@Test
243259
fun otherWrausesCause() {
244260
val cause = RuntimeException("root cause")

0 commit comments

Comments
 (0)