Skip to content

Commit 79c5e59

Browse files
Fix Go transform JSON serialization: add json tags for content field
The systemMessageTransformRequest and systemMessageTransformResponse used anonymous structs without json tags, causing Content to serialize as uppercase 'Content' instead of lowercase 'content'. The CLI expects lowercase, so transform results were silently ignored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2063bc8 commit 79c5e59

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

go/session.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,27 @@ func (s *Session) registerTransformCallbacks(callbacks map[string]SectionTransfo
458458
s.transformCallbacks = callbacks
459459
}
460460

461+
type systemMessageTransformSection struct {
462+
Content string `json:"content"`
463+
}
464+
461465
type systemMessageTransformRequest struct {
462-
SessionID string `json:"sessionId"`
463-
Sections map[string]struct{ Content string } `json:"sections"`
466+
SessionID string `json:"sessionId"`
467+
Sections map[string]systemMessageTransformSection `json:"sections"`
464468
}
465469

466470
type systemMessageTransformResponse struct {
467-
Sections map[string]struct{ Content string } `json:"sections"`
471+
Sections map[string]systemMessageTransformSection `json:"sections"`
468472
}
469473

470474
// handleSystemMessageTransform handles a system message transform request from the Copilot CLI.
471475
// This is an internal method called by the SDK when the CLI requests section transforms.
472-
func (s *Session) handleSystemMessageTransform(sections map[string]struct{ Content string }) (systemMessageTransformResponse, error) {
476+
func (s *Session) handleSystemMessageTransform(sections map[string]systemMessageTransformSection) (systemMessageTransformResponse, error) {
473477
s.transformMu.Lock()
474478
callbacks := s.transformCallbacks
475479
s.transformMu.Unlock()
476480

477-
result := make(map[string]struct{ Content string })
481+
result := make(map[string]systemMessageTransformSection)
478482
for sectionID, data := range sections {
479483
var callback SectionTransformFn
480484
if callbacks != nil {
@@ -483,12 +487,12 @@ func (s *Session) handleSystemMessageTransform(sections map[string]struct{ Conte
483487
if callback != nil {
484488
transformed, err := callback(data.Content)
485489
if err != nil {
486-
result[sectionID] = struct{ Content string }{Content: data.Content}
490+
result[sectionID] = systemMessageTransformSection{Content: data.Content}
487491
} else {
488-
result[sectionID] = struct{ Content string }{Content: transformed}
492+
result[sectionID] = systemMessageTransformSection{Content: transformed}
489493
}
490494
} else {
491-
result[sectionID] = struct{ Content string }{Content: data.Content}
495+
result[sectionID] = systemMessageTransformSection{Content: data.Content}
492496
}
493497
}
494498
return systemMessageTransformResponse{Sections: result}, nil

0 commit comments

Comments
 (0)