Skip to content

Add license, tests, CI and governance; harden multipart file read - #1

Merged
AjmalAlkhaledi merged 2 commits into
1.xfrom
chore/oss-hardening
Nov 2, 2026
Merged

AjmalAlkhaledi merged 2 commits into
1.xfrom
chore/oss-hardening

Conversation

@AjmalAlkhaledi

@AjmalAlkhaledi AjmalAlkhaledi commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Hardens packaging and trust for astrahttp/http without touching the public API.

  • LICENSE — adds MIT LICENSE (composer.json already declared MIT; the file was missing).
  • Tests — new PHPUnit suite for the pure-PHP units that do not need the Go worker: MultipartEncoder, PacketBuffer, RequestOptions::toTransportArray(). 27 tests, 51 assertions, green on PHP 8.4.
  • CI — .github/workflows/ci.yml: PHP matrix 8.2/8.3/8.4 (composer validate --strict + lint + test) and a Go job (go build / go vet in src-go).
  • Governance — CONTRIBUTING, SECURITY, CODE_OF_CONDUCT, CHANGELOG, issue + PR templates.
  • Bug fixes —
    • MultipartEncoder::encode() validates file readability before reading, throwing AstraException cleanly instead of emitting a raw PHP warning.
    • Go transport: SSE/WebSocket read loops now terminate correctly (labeled break) so the trailing "end" frame is sent; processRequest no longer leaks a cancellable context on protocol early-return paths. (Both surfaced by go vet.)
  • Hygiene — aligned composer.json description; export-ignore dev files from the Composer dist; gitignore composer.lock and .phpunit.cache.

Verification

composer validate --strict   # ./composer.json is valid
composer lint                # No syntax errors
vendor/bin/phpunit           # OK (27 tests, 51 assertions)
go build ./...               # (src-go) ok

CI: all green (PHP 8.2/8.3/8.4 + Go transport).

No secrets or binaries committed. Public API (Client, RequestOptions, Response) unchanged.

AjmalAlkhaledi and others added 2 commits November 2, 2026 16:45
- Add MIT LICENSE (composer.json already declared MIT; file was missing)
- Add PHPUnit suite for pure-PHP units: MultipartEncoder, PacketBuffer,
  RequestOptions::toTransportArray() (27 tests, 51 assertions)
- Add GitHub Actions CI: PHP 8.2-8.4 (validate/lint/test) + Go build/vet
- Add CONTRIBUTING, SECURITY, CODE_OF_CONDUCT, CHANGELOG, issue/PR templates
- MultipartEncoder::encode(): validate file readability before reading, so a
  missing/unreadable path throws AstraException cleanly instead of emitting a
  raw PHP warning
- Align composer.json description; export-ignore dev files from the dist;
  gitignore composer.lock and .phpunit.cache

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
go vet (added in CI) surfaced real issues in the Go transport:

- SSE and WebSocket read loops used `break` inside a `select`, which only
  breaks the select, not the enclosing `for {}`. The loops never terminated
  on EOF / normal close / cancellation: a spin after the stream ended and the
  trailing "end" frame was unreachable (never sent to PHP). Use labeled
  `break sseLoop` / `break wsLoop` so the loop exits and the end frame is sent.
- processRequest created a cancellable context before the protocol dispatch,
  leaking it on the websocket/sse/http3 early-return paths (which manage their
  own). Create it only on the default HTTP path that uses it.

Fixes: core.go unreachable-code (977, 1176) and lostcancel (132) vet findings.
go build ./... passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AjmalAlkhaledi
AjmalAlkhaledi merged commit 05c1783 into 1.x Nov 2, 2026
4 checks passed
@AjmalAlkhaledi
AjmalAlkhaledi deleted the chore/oss-hardening branch November 2, 2026 18:05
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.

1 participant