{"record":{"id":"2adc86a2dc2b5433","repo":"sipeed/picoclaw","slug":"failed-to-write-response-format-field-w","errorCode":null,"errorMessage":"failed to write response_format field: %w","messagePattern":"failed to write response_format field: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/audio/asr/whisper_transcriber.go","lineNumber":122,"sourceCode":"\tpart, err := writer.CreateFormFile(\"file\", filename)\n\tif err != nil {\n\t\tlogger.ErrorCF(\"voice\", \"Failed to create whisper form file\", map[string]any{\"error\": err})\n\t\treturn nil, fmt.Errorf(\"failed to create form file: %w\", err)\n\t}\n\n\tif _, copyErr := io.Copy(part, bytes.NewReader(data)); copyErr != nil {\n\t\tlogger.ErrorCF(\"voice\", \"Failed to copy whisper file content\", map[string]any{\"error\": copyErr})\n\t\treturn nil, fmt.Errorf(\"failed to copy file content: %w\", copyErr)\n\t}\n\n\tif err = writer.WriteField(\"model\", t.modelID); err != nil {\n\t\tlogger.ErrorCF(\"voice\", \"Failed to write whisper model field\", map[string]any{\"error\": err})\n\t\treturn nil, fmt.Errorf(\"failed to write model field: %w\", err)\n\t}\n\n\tif err = writer.WriteField(\"response_format\", \"json\"); err != nil {\n\t\tlogger.ErrorCF(\"voice\", \"Failed to write whisper response_format field\", map[string]any{\"error\": err})\n\t\treturn nil, fmt.Errorf(\"failed to write response_format field: %w\", err)\n\t}\n\n\tif err = writer.Close(); err != nil {\n\t\tlogger.ErrorCF(\"voice\", \"Failed to close whisper multipart writer\", map[string]any{\"error\": err})\n\t\treturn nil, fmt.Errorf(\"failed to close multipart writer: %w\", err)\n\t}\n\n\treturn t.doRequest(ctx, &requestBody, writer.FormDataContentType(), int64(len(data)))\n}\n\nfunc (t *WhisperTranscriber) Transcribe(ctx context.Context, audioFilePath string) (*TranscriptionResponse, error) {\n\tlogger.InfoCF(\"voice\", \"Starting whisper transcription\", map[string]any{\n\t\t\"audio_file\": audioFilePath,\n\t\t\"model\":      t.modelID,\n\t\t\"provider\":   t.providerName,\n\t})\n\n\taudioFile, err := os.Open(audioFilePath)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/audio/asr/whisper_transcriber.go#L104-L140","documentation":"Thrown when writer.WriteField(\"response_format\", \"json\") fails in WhisperTranscriber's multipart builder. The value is the compile-time constant \"json\", so no input can make the field itself invalid; only a bytes.Buffer write/allocation failure under memory exhaustion triggers it. Companion of 315 one line later.","triggerScenarios":"Memory allocation failure during multipart buffering of a large audio payload.","commonSituations":"Same memory-pressure profile as 314/315.","solutions":["Same remediation as 315: bound input size, raise limits, pre-grow the buffer."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if len(data) > maxInMemoryAudio { return errors.New(\"audio too large for in-memory multipart build\") }","typeGuard":null,"tryCatchPattern":"if _, err := whisper.TranscribeWithData(ctx, data, name); err != nil {\n    // Constant field write failed: memory exhaustion; same handling as 314/315.\n    return err\n}","preventionTips":["Bound audio size; the value written here is a constant so input quality is never the cause.","Group this with the other buffer-write errors when monitoring."],"tags":["memory","multipart","whisper","go"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}