mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-01 18:19:50 -05:00
* fix(whisper): honour positional listen address argument The whisper backend parsed its gRPC listen address exclusively through Go's flag package, while run.sh forwards launcher arguments verbatim. A bare positional address was silently dropped by flag.Parse(), so the server always bound the default localhost:50051 instead of the port its caller allocated — LocalAI then failed to reach it with a misleading 'error reading from server: EOF'. Fall back to the first positional argument when no explicit -addr value was given, keeping the default for no-argument launches. Fixes #11623 Assisted-by: ox-alpha:ox-alpha [go test] Signed-off-by: Som Samantray <som.samantray@gmail.com> * fix(whisper): track explicit -addr via flag.Visit and adopt Ginkgo test style Review follow-up: - Detect an explicitly set -addr with flag.FlagSet.Visit instead of comparing against the default sentinel, so '-addr localhost:50051' plus a positional argument keeps the flag value. - Treat an explicitly empty -addr as unset rather than binding the empty address (OS-chosen port on all interfaces). - Rewrite addr_test.go as Ginkgo v2 specs per .agents/coding-style.md; stdlib t.Run/t.Errorf are forbidden by .golangci.yml forbidigo. Assisted-by: ox-alpha:ox-alpha [go test] Signed-off-by: Som Samantray <som.samantray@gmail.com> --------- Signed-off-by: Som Samantray <som.samantray@gmail.com>
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
// Specs for resolveAddr run under the suite bootstrap in gowhisper_test.go
|
|
// (TestWhisper); they need no native library, so they never skip.
|
|
var _ = Describe("resolveAddr", func() {
|
|
It("prefers an explicitly set -addr over a positional argument", func() {
|
|
Expect(resolveAddr("127.0.0.1:12345", true, []string{"127.0.0.1:59999"})).To(Equal("127.0.0.1:12345"))
|
|
})
|
|
|
|
It("keeps an explicit -addr equal to the default over a positional argument", func() {
|
|
Expect(resolveAddr(defaultAddr, true, []string{"127.0.0.1:59999"})).To(Equal(defaultAddr))
|
|
})
|
|
|
|
It("falls back to the positional argument when -addr is unset", func() {
|
|
Expect(resolveAddr(defaultAddr, false, []string{"127.0.0.1:59999"})).To(Equal("127.0.0.1:59999"))
|
|
})
|
|
|
|
It("keeps the default when -addr is unset and no positional argument is given", func() {
|
|
Expect(resolveAddr(defaultAddr, false, nil)).To(Equal(defaultAddr))
|
|
})
|
|
|
|
It("uses the first positional argument among several", func() {
|
|
Expect(resolveAddr(defaultAddr, false, []string{"127.0.0.1:59999", "extra"})).To(Equal("127.0.0.1:59999"))
|
|
})
|
|
|
|
It("treats an explicitly empty -addr as unset", func() {
|
|
Expect(resolveAddr("", true, []string{"127.0.0.1:59999"})).To(Equal("127.0.0.1:59999"))
|
|
Expect(resolveAddr("", true, nil)).To(Equal(defaultAddr))
|
|
})
|
|
})
|