Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

docs(sdk): trim comments on the deserialize-failure fix

高然c210c413e0bd
diff --git a/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/Serializer.kt b/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/Serializer.kt
index 9772d0533..a122e96b3 100644
--- a/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/Serializer.kt
+++ b/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/Serializer.kt
@@ -37,20 +37,9 @@ internal val jsonParser =
coerceInputValues = true
}
-/** Upper bound for response payloads embedded in decode-failure messages. */
internal const val DECODE_FAILURE_PAYLOAD_LIMIT = 2048
-/**
- * Decodes a raw HTTP response body, converting deserialization failures into a
- * [SandboxInternalException] whose message keeps the raw payload (truncated to
- * [DECODE_FAILURE_PAYLOAD_LIMIT] characters) so the server's actual response is
- * never lost to the failure itself.
- *
- * Covers both [Exception]s (e.g. SerializationException) and [LinkageError]s
- * (e.g. AbstractMethodError from a serializer/runtime version mismatch): the
- * latter is an `Error`, so adapter-level `catch (Exception)` blocks would
- * otherwise let it escape without any response context.
- */
+/** Decodes a response body, keeping the raw payload (truncated) in the thrown [SandboxInternalException] on failure. */
internal fun <T> Json.decodeResponseBody(
serializer: KSerializer<T>,
payload: String,
diff --git a/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupport.kt b/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupport.kt
index 1e35a74e6..b0abb446c 100644
--- a/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupport.kt
+++ b/sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupport.kt
@@ -28,11 +28,8 @@ public object ExecdEventSupport {
*
* [onError] is invoked with the raw line for payloads that fail to parse;
* callers must pass it so malformed SSE lines are never dropped silently.
- *
- * A [LinkageError] (e.g. `AbstractMethodError` from a serializer/runtime
- * version mismatch) is systemic: the raw line is reported through [onError]
- * and then the error is rethrown, because skipping every event would turn
- * the failure into a silent stream death.
+ * A [LinkageError] is reported and rethrown instead of skipped, because
+ * skipping every event would turn the failure into a silent stream death.
*/
public fun decodeEventLine(
line: String,
diff --git a/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/ResponseBodyDecodingTest.kt b/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/ResponseBodyDecodingTest.kt
index 9804f7e3e..f820f0056 100644
--- a/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/ResponseBodyDecodingTest.kt
+++ b/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/ResponseBodyDecodingTest.kt
@@ -35,7 +35,6 @@ class ResponseBodyDecodingTest {
@Serializable
private data class Sample(val id: String)
- /** Serializer whose deserialize throws the given throwable, emulating e.g. a broken generated serializer. */
private class FailingSerializer(
private val error: Throwable,
) : KSerializer<Sample> {
@@ -72,9 +71,6 @@ class ResponseBodyDecodingTest {
@Test
fun `wraps linkage errors such as AbstractMethodError with the raw body`() {
- // LinkageError is an Error, not an Exception: without an explicit catch
- // branch it would escape every adapter-level catch (Exception) block and
- // the raw response body would be lost entirely.
val boom = AbstractMethodError("missing typeParametersSerializers()")
val thrown =
assertThrows<SandboxInternalException> {
diff --git a/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupportTest.kt b/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupportTest.kt
index 45542fbb5..716d475a0 100644
--- a/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupportTest.kt
+++ b/sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/ExecdEventSupportTest.kt
@@ -89,8 +89,6 @@ class ExecdEventSupportTest {
@Test
fun `reports linkage errors through onError and rethrows them`() {
- // Serializer/runtime version mismatches surface as AbstractMethodError,
- // an Error subtype that plain catch (Exception) blocks never see.
val boom = AbstractMethodError("missing typeParametersSerializers()")
val linkageReported = mutableListOf<Pair<String, Throwable>>()
val rawLine = """data: {"type":"error","timestamp":1}"""