googleapis/mcp-toolbox · error
failed to unmarshal session template JSON: %w
Error message
failed to unmarshal session template JSON: %w
What it means
encoding/json.Unmarshal failed to decode the protojson output into map[string]any in GetSessionTemplate — the serialized template contained a JSON construct the decoder rejects.
Source
Thrown at internal/sources/serverlessspark/serverlessspark.go:347
func (s *Source) GetSessionTemplate(ctx context.Context, name string) (map[string]any, error) {
client := s.GetSessionTemplateControllerClient()
req := &dataprocpb.GetSessionTemplateRequest{
Name: fmt.Sprintf("projects/%s/locations/%s/sessionTemplates/%s", s.GetProject(), s.GetLocation(), name),
}
sessionTemplatePb, err := client.GetSessionTemplate(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get session template: %w", err)
}
jsonBytes, err := protojson.Marshal(sessionTemplatePb)
if err != nil {
return nil, fmt.Errorf("failed to marshal session template to JSON: %w", err)
}
var result map[string]any
if err := json.Unmarshal(jsonBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal session template JSON: %w", err)
}
wrappedResult := map[string]any{
"sessionTemplate": result,
}
return wrappedResult, nil
}
// ToSessionTemplates converts a slice of protobuf SessionTemplate messages to a slice of SessionTemplate structs.
func ToSessionTemplates(sessionTemplatePbs []*dataprocpb.SessionTemplate) ([]SessionTemplate, error) {
sessionTemplates := make([]SessionTemplate, 0, len(sessionTemplatePbs))
for _, sessionTemplatePb := range sessionTemplatePbs {
sessionTemplate := SessionTemplate{
Name: sessionTemplatePb.Name,
Description: sessionTemplatePb.Description,
Creator: sessionTemplatePb.Creator,View on GitHub (pinned to 8cc6e09de2)
Solutions
- Retry the fetch
- Inspect logs for the offending JSON
- Report consistently failing templates upstream
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/sources/serverlessspark/serverlessspark.go:347 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/2672a535db618ef8.
Report an issue: GitHub.