Skip to content

bug: post() HTTP helper silently ignores error status codes #25

Description

@gitcoder89431

Problem

The post() helper in internal/syncthing/client.go never checks resp.StatusCode, so any HTTP 4xx/5xx response is silently swallowed as nil:

func (c *Client) post(path string) error {
    ...
    defer resp.Body.Close()
    return nil // ← no status check
}

This affects callers:

  • AddIgnorePattern — silently fails to trigger rescan after writing .stignore
  • EnsureMeshdFolder — silently fails the post-ignore scan on existing folders

Fix

Mirror the same check used in put() and delete():

if resp.StatusCode >= 400 {
    b, _ := io.ReadAll(resp.Body)
    return fmt.Errorf("syncthing POST %s: %s — %s", path, resp.Status, b)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions