Skip to content

Make HTTP client timeout configurable via existing -t/--timeout flag - #98

Merged
martialblog merged 2 commits into
NETWAYS:mainfrom
hb-andy:fix-hardcoded-http-timeout
Aug 13, 2026
Merged

Make HTTP client timeout configurable via existing -t/--timeout flag#98
martialblog merged 2 commits into
NETWAYS:mainfrom
hb-andy:fix-hardcoded-http-timeout

Conversation

@hb-andy

@hb-andy hb-andy commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

The HTTP client used internally in api/client.go had a hardcoded timeout
of 5 seconds (DefaultTimeout = 5), completely independent of the
-t/--timeout flag exposed via the go-check library (defaults to 30s).

As soon as a request to the SentinelOne API takes longer than 5 seconds,
the check fails with:

HTTP request failed: Get "...": context deadline exceeded
(Client.Timeout exceeded while awaiting headers)

...no matter what value is passed via -t. We ran into this in
production: our SentinelOne threats query started taking ~11-12s to
respond (confirmed independently via curl, which succeeded fine), while
the plugin kept failing every single time, since 11s > the hardcoded 5s.

Fix

  • api.NewClient() now takes an explicit timeout time.Duration
    parameter instead of relying on the hardcoded constant.
  • Config (in check.go) gets a Timeout time.Duration field, passed
    through to api.NewClient().
  • main.go sets config.Timeout from plugin.Timeout (the existing
    -t/--timeout flag) after parsing arguments.
  • DefaultTimeout (5s) is kept as-is and only used as a fallback if
    NewClient is called with a zero/negative duration.

This is a minimal, behavior-preserving change: the effective default
timeout stays the same (30s from the existing flag default), but it's
now actually possible to tune it.

Testing

Verified locally against a real SentinelOne instance:

  • Without -t: succeeds (falls back to the default 30s, comfortably
    above the ~11s the API currently needs to respond).
  • With -t 1: fails fast with a timeout error, confirming the flag now
    actually controls the HTTP client timeout.

Previously the HTTP client used a hardcoded 5 second timeout,
independent of the --timeout flag. This caused requests to fail
whenever the SentinelOne API took longer than 5s to respond,
regardless of the timeout configured by the user.
@martialblog martialblog self-assigned this Aug 13, 2026
@martialblog

Copy link
Copy Markdown
Member

Hi, thanks for the PR. Looks good, but you probably need to update the test cases as well.

@hb-andy

hb-andy commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Hi. Good catch, thanks! Updated api/client_test.go to match the new NewClient signature. go test ./... passes locally now.

@martialblog
martialblog merged commit 7c3087e into NETWAYS:main Aug 13, 2026
2 checks passed
@martialblog

Copy link
Copy Markdown
Member

Thanks for the contribution. I'll try to create a new release soon.

@hb-andy
hb-andy deleted the fix-hardcoded-http-timeout branch August 13, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants