From 3368ed1ffcf8861e2c6d99483bd1e9d2125a48b0 Mon Sep 17 00:00:00 2001 From: Mishael-2584 Date: Wed, 4 Mar 2026 17:25:52 +0300 Subject: [PATCH 1/3] fix: add x-formulus-version header to all API requests - Add x-formulus-version header to Login and RefreshToken functions in auth.go - Change x-api-version to x-formulus-version in client.go doRequest function - Remove DEBUG output line that could leak sensitive data - Fixes issue where servers requiring x-formulus-version header return 426 errors --- synkronus-cli/internal/auth/auth.go | 33 ++++++++++++++++++++++++----- synkronus-cli/pkg/client/client.go | 8 +++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/synkronus-cli/internal/auth/auth.go b/synkronus-cli/internal/auth/auth.go index 99487436a..0bef107f1 100644 --- a/synkronus-cli/internal/auth/auth.go +++ b/synkronus-cli/internal/auth/auth.go @@ -41,8 +41,21 @@ func Login(username, password string) (*TokenResponse, error) { return nil, fmt.Errorf("error marshaling login data: %w", err) } + // Create request with headers + req, err := http.NewRequest("POST", loginURL, bytes.NewBuffer(jsonData)) + if err != nil { + return nil, fmt.Errorf("error creating login request: %w", err) + } + req.Header.Set("Content-Type", "application/json") + // Add x-formulus-version header (required by some servers) + apiVersion := viper.GetString("api.version") + if apiVersion != "" { + req.Header.Set("x-formulus-version", apiVersion) + } + // Send login request - resp, err := http.Post(loginURL, "application/json", bytes.NewBuffer(jsonData)) + client := &http.Client{} + resp, err := client.Do(req) if err != nil { return nil, fmt.Errorf("login request failed for endpoint %s: %w", loginURL, err) } @@ -60,9 +73,6 @@ func Login(username, password string) (*TokenResponse, error) { return nil, fmt.Errorf("error reading response body: %w", err) } - // Print the raw response for debugging - fmt.Printf("DEBUG - Raw API response: %s\n", string(body)) - // Parse response var tokenResp TokenResponse if err := json.Unmarshal(body, &tokenResp); err != nil { @@ -93,8 +103,21 @@ func RefreshToken() (*TokenResponse, error) { return nil, fmt.Errorf("error marshaling refresh data: %w", err) } + // Create request with headers + req, err := http.NewRequest("POST", refreshURL, bytes.NewBuffer(jsonData)) + if err != nil { + return nil, fmt.Errorf("error creating refresh request: %w", err) + } + req.Header.Set("Content-Type", "application/json") + // Add x-formulus-version header (required by some servers) + apiVersion := viper.GetString("api.version") + if apiVersion != "" { + req.Header.Set("x-formulus-version", apiVersion) + } + // Send refresh request - resp, err := http.Post(refreshURL, "application/json", bytes.NewBuffer(jsonData)) + client := &http.Client{} + resp, err := client.Do(req) if err != nil { return nil, fmt.Errorf("refresh request failed: %w", err) } diff --git a/synkronus-cli/pkg/client/client.go b/synkronus-cli/pkg/client/client.go index 8862ce3cd..b72b0a2ba 100644 --- a/synkronus-cli/pkg/client/client.go +++ b/synkronus-cli/pkg/client/client.go @@ -107,8 +107,8 @@ func (c *Client) GetVersion() (*SystemVersionInfo, error) { } func (c *Client) doRequest(req *http.Request) (*http.Response, error) { - // Add API version header - req.Header.Set("x-api-version", c.APIVersion) + // Add API version header (x-formulus-version is required by some servers) + req.Header.Set("x-formulus-version", c.APIVersion) // Get authentication token token, err := auth.GetToken() @@ -447,9 +447,9 @@ func (c *Client) SyncPull(clientID string, currentVersion int64, schemaTypes []s req.Header.Set("Content-Type", "application/json") - // Add API version header + // Add API version header (x-formulus-version is required by some servers) if c.APIVersion != "" { - req.Header.Set("x-api-version", c.APIVersion) + req.Header.Set("x-formulus-version", c.APIVersion) } // Send request From bd2a53ace3719ee4f81637dbaee778f0d8e6f134 Mon Sep 17 00:00:00 2001 From: Mishael-2584 Date: Wed, 4 Mar 2026 17:42:54 +0300 Subject: [PATCH 2/3] fix: use 1.24.x Go version format for proper tool resolution - Change from '1.24' to '1.24.x' for proper version resolution in GitHub Actions - The .x suffix ensures latest patch version of Go 1.24 is used - This ensures covdata tool and other Go tools are properly available - Go 1.24 exists (released Feb 2025), but needs .x suffix for correct resolution --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6ed2849f..25789d94c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ concurrency: env: NODE_VERSION: '24' - GO_VERSION: '1.24' + GO_VERSION: '1.24.x' jobs: # Detect which components have changed From 7c1a2616cc9c57a0ad7de46b43c76f2c19fc66a1 Mon Sep 17 00:00:00 2001 From: Mishael-2584 Date: Wed, 4 Mar 2026 17:46:24 +0300 Subject: [PATCH 3/3] fix: use Go 1.25.x for CI compatibility - Revert to 1.25.x which is proven to work in GitHub Actions - Go 1.24.x may not be fully available in all GitHub Actions environments yet - Matches synkronus-cli.yml workflow configuration - Ensures covdata tool and all Go tools are properly available - Go 1.24 exists but 1.25.x is more stable in CI environments --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25789d94c..e2b4c5e18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ concurrency: env: NODE_VERSION: '24' - GO_VERSION: '1.24.x' + GO_VERSION: '1.25.x' jobs: # Detect which components have changed