Harden HTTP client: no redirects, HTTPS-only, bounded bodies, safe errors, UA, ctx, GET retries #3

Merged
john merged 0 commits from refs/pull/3/head into main 2026-11-16 21:17:13 +00:00
john commented 2026-11-16 15:17:22 +00:00 (Migrated from code.yawn.dev)

Batch 1 of the provider gap fixes.

Change Why
Never follow redirects Go copies X-API-Key onto redirected requests, even to another host; 301/302 also turns POST into GET
https:// only, http:// for loopback Key and secret values must not travel unencrypted
32 MiB response limit A broken endpoint cannot exhaust memory during plan/apply
Status checked before JSON decode Proxy 502/504 pages report their status, not a decode error
Error text: at most 256 bytes, control characters removed, never request bodies Keeps payloads and secrets out of CI logs
User-Agent: tofu-provider-xyops/<version> Provider traffic is identifiable in xyOps logs
Requests carry the operation context Ctrl-C and OpenTofu cancellation stop in-flight calls
GET retried 3x on 429/502/503/504 and connection errors, Retry-After up to 10s; POST never Rides out brief xyOps restarts without risking duplicate writes
request_timeout_seconds / XYOPS_REQUEST_TIMEOUT_SECONDS (1-600, default 30) Slow admin actions can get more time

Other internal/provider changes only pass the context through. README, docs/index.md and CHANGELOG.md updated.

Local check.sh: gofmt, go mod verify, vet, tests, govulncheck (0 reachable) and version tests all pass.

Batch 1 of the provider gap fixes. | Change | Why | |---|---| | Never follow redirects | Go copies `X-API-Key` onto redirected requests, even to another host; 301/302 also turns POST into GET | | `https://` only, `http://` for loopback | Key and secret values must not travel unencrypted | | 32 MiB response limit | A broken endpoint cannot exhaust memory during plan/apply | | Status checked before JSON decode | Proxy 502/504 pages report their status, not a decode error | | Error text: at most 256 bytes, control characters removed, never request bodies | Keeps payloads and secrets out of CI logs | | `User-Agent: tofu-provider-xyops/<version>` | Provider traffic is identifiable in xyOps logs | | Requests carry the operation context | Ctrl-C and OpenTofu cancellation stop in-flight calls | | GET retried 3x on 429/502/503/504 and connection errors, `Retry-After` up to 10s; POST never | Rides out brief xyOps restarts without risking duplicate writes | | `request_timeout_seconds` / `XYOPS_REQUEST_TIMEOUT_SECONDS` (1-600, default 30) | Slow admin actions can get more time | Other `internal/provider` changes only pass the context through. README, `docs/index.md` and `CHANGELOG.md` updated. Local `check.sh`: gofmt, `go mod verify`, vet, tests, govulncheck (0 reachable) and version tests all pass.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
john/tofu-provider-xyops!3
No description provided.