Stop serializing FunctionCall/Result Error to match .NET JsonIgnore Exception - #625
Conversation
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
db2295b to
df7ffef
Compare
df7ffef to
bbaf6fd
Compare
This comment has been minimized.
This comment has been minimized.
bbaf6fd to
6985390
Compare
This comment has been minimized.
This comment has been minimized.
.NET marks FunctionCallContent.Exception and FunctionResultContent.Exception with [JsonIgnore], so they are never persisted. The Go port instead wrote the error as an Error string and reconstructed a synthetic errors.New on unmarshal, diverging from .NET/Python and fabricating an error value that was never in the serialized payload. Drop the Error field from the serialized structs so the in-memory Error stays informational-only and is not round-tripped.
6985390 to
b15a84e
Compare
|
PratikDhanave (@PratikDhanave) linter issue |
This comment has been minimized.
This comment has been minimized.
|
Copilot fix the failing linter checks |
# Conflicts: # message/content_test.go
Head branch was pushed to by a user without write access
This comment has been minimized.
This comment has been minimized.
# Conflicts: # message/content_test.go
Parity Review — ✅ ApprovedPR scope: Upstream verification:
Go contract mapping:
Verdict: This PR restores cross-SDK wire-format parity. The
|
What
Remove the
Errorfield fromserializedFunctionCallContentandserializedFunctionResultContent, and drop the marshal/unmarshal logic that persisted it as a string and reconstructed it viaerrors.New. The in-memoryError errorfield onFunctionCallContentandFunctionResultContentstays as informational-only state.Why
In .NET, both
FunctionCallContent.ExceptionandFunctionResultContent.Exceptioncarry[JsonIgnore]and are never serialized. Python behaves the same way. The Go port instead serialized the error to anErrorstring and, on unmarshal, fabricated a syntheticerrors.New(...)that was never part of the original object graph. That diverges from the other SDKs and reconstructs an error value with a lost type/wrapping that the producer never intended to persist. This change aligns the wire format with .NET/Python: the exception is a local mapping/diagnostic detail, not serialized state.Tests
TestFunctionCallContent_ErrorNotSerializedandTestFunctionResultContent_ErrorNotSerializedinmessage/content_test.go: marshaling a content with a non-nilErrorproduces JSON with noErrorkey, and unmarshaling JSON without anErrorkey yields a nilErrorfield.TestContentEncoding_Roundtripto drop theErrorit previously set onFunctionResultContent, since that value is intentionally no longer round-tripped.go build ./...,go vet ./message/..., andgo test ./message/...all pass.