Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion daemon/ccotel_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,15 @@ func (p *CCOtelProcessor) parseLogRecord(lr *logsv1.LogRecord, resourceAttrs *mo
case "tool_name":
event.ToolName = value.GetStringValue()
case "success":
event.Success = value.GetBoolValue()
event.Success = getBoolFromValue(value)
case "decision":
event.Decision = value.GetStringValue()
// case "decision_source":
// event.DecisionSource = value.GetStringValue()
// case "decision_type":
// event.DecisionType = value.GetStringValue()
// case "tool_result_size_bytes":
// event.ToolResultSizeBytes = getIntFromValue(value)
Comment on lines +414 to +419
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out code should be removed. If this functionality is planned for the future, it should be tracked in an issue rather than being left as dead code in the codebase, as it reduces readability.

case "source":
event.Source = value.GetStringValue()
case "error":
Expand Down Expand Up @@ -530,6 +536,20 @@ func getIntFromValue(value *commonv1.AnyValue) int {
return 0
}

func getBoolFromValue(value *commonv1.AnyValue) bool {
// First try to get as bool
if boolVal := value.GetBoolValue(); boolVal {
return boolVal
}
// Try to parse from string (Claude Code sends some values as strings)
if strVal := value.GetStringValue(); strVal != "" {
if parsed, err := strconv.ParseBool(strVal); err == nil {
return parsed
}
}
return false
}
Comment on lines +539 to +551
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This function can panic if value is nil. The value comes from attr.GetValue(), which can return nil and would cause a panic on value.GetBoolValue(). You should add a nil check at the beginning of the function.

Additionally, the current implementation is a bit difficult to follow. A type switch on value.Value would be more idiomatic for handling protobuf oneof fields, making the logic clearer and more robust.

Suggested change
func getBoolFromValue(value *commonv1.AnyValue) bool {
// First try to get as bool
if boolVal := value.GetBoolValue(); boolVal {
return boolVal
}
// Try to parse from string (Claude Code sends some values as strings)
if strVal := value.GetStringValue(); strVal != "" {
if parsed, err := strconv.ParseBool(strVal); err == nil {
return parsed
}
}
return false
}
func getBoolFromValue(value *commonv1.AnyValue) bool {
if value == nil {
return false
}
switch v := value.Value.(type) {
case *commonv1.AnyValue_BoolValue:
return v.BoolValue
case *commonv1.AnyValue_StringValue:
if parsed, err := strconv.ParseBool(v.StringValue); err == nil {
return parsed
}
}
return false
}


// getFloatFromValue extracts a float64 from an OTEL value, handling both double and string formats
func getFloatFromValue(value *commonv1.AnyValue) float64 {
// First try to get as double
Expand Down