From c2be0e8c9a689025f2fa58cef3cc1d7aa764c7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=84=E6=BD=AD?= Date: Fri, 13 Feb 2026 09:03:06 +0800 Subject: [PATCH] fix(ai-statistics): add ValueSource to built-in attributes for streaming body buffering (#3491) --- .../wasm-go/extensions/ai-statistics/main.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/wasm-go/extensions/ai-statistics/main.go b/plugins/wasm-go/extensions/ai-statistics/main.go index 02e9902e9..ea42c54b5 100644 --- a/plugins/wasm-go/extensions/ai-statistics/main.go +++ b/plugins/wasm-go/extensions/ai-statistics/main.go @@ -430,6 +430,26 @@ func parseConfig(configJson gjson.Result, config *AIStatisticsConfig) error { config.valueLengthLimit = 10485760 // 10MB } log.Infof("Using default attributes configuration") + // Check if any default attribute needs streaming body buffering + for _, attribute := range config.attributes { + if attribute.ValueSource == ResponseStreamingBody { + config.shouldBufferStreamingBody = true + break + } + // For built-in attributes without explicit ValueSource, check default sources + if attribute.ValueSource == "" && isBuiltinAttribute(attribute.Key) { + defaultSources := getBuiltinAttributeDefaultSources(attribute.Key) + for _, src := range defaultSources { + if src == ResponseStreamingBody { + config.shouldBufferStreamingBody = true + break + } + } + if config.shouldBufferStreamingBody { + break + } + } + } } else { config.attributes = make([]Attribute, len(attributeConfigs)) for i, attributeConfig := range attributeConfigs {