Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(cli): preserve integer precision in jq output (#3991)
LeonSGPff33184433c4
diff --git a/cli/cmd/auth/status_jq_precision_test.go b/cli/cmd/auth/status_jq_precision_test.gonew file mode 100644index 000000000..4f1648054--- /dev/null+++ b/cli/cmd/auth/status_jq_precision_test.go@@ -0,0 +1,32 @@+package auth++import (+ "context"+ "net/http"+ "net/http/httptest"+ "testing"++ "github.com/Tencent/WeKnora/cli/internal/cmdutil"+ "github.com/Tencent/WeKnora/cli/internal/config"+ "github.com/Tencent/WeKnora/cli/internal/iostreams"+ sdk "github.com/Tencent/WeKnora/client"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++func TestStatusJQPreservesTenantID(t *testing.T) {+ out, _ := iostreams.SetForTest(t)+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ assert.Equal(t, "/api/v1/auth/me", r.URL.Path)+ _, _ = w.Write([]byte(`{"success":true,"data":{"user":{"id":"user-test","tenant_id":9007199254740993}}}`))+ }))+ defer server.Close()+ f := &cmdutil.Factory{Config: func() (*config.Config, error) {+ return &config.Config{CurrentProfile: "test", Profiles: map[string]config.Profile{+ "test": {Host: server.URL},+ }}, nil+ }}+ require.NoError(t, runStatus(context.Background(),+ &cmdutil.FormatOptions{Mode: cmdutil.FormatJSON, JQ: ".data.tenant_id"}, f, sdk.NewClient(server.URL)))+ assert.Equal(t, "9007199254740993\n", out.String())+}diff --git a/cli/internal/format/filter.go b/cli/internal/format/filter.goindex 1a70b7e74..cd4c06336 100644--- a/cli/internal/format/filter.go+++ b/cli/internal/format/filter.go@@ -69,7 +69,9 @@ func writeJQ(w io.Writer, raw []byte, expr string) error {return &JQError{Err: fmt.Errorf("jq parse: %w", err)}}var input any- if err := json.Unmarshal(raw, &input); err != nil {+ decoder := json.NewDecoder(bytes.NewReader(raw))+ decoder.UseNumber()+ if err := decoder.Decode(&input); err != nil {return fmt.Errorf("jq input parse: %w", err)}iter := query.Run(input)