Skip to content

Fix PR #22 review findings: config edge cases and token type guard - #23

Merged
mathiasgrimm merged 2 commits into
mainfrom
pr22-review-followups
Jul 17, 2026
Merged

Fix PR #22 review findings: config edge cases and token type guard#23
mathiasgrimm merged 2 commits into
mainfrom
pr22-review-followups

Conversation

@mathiasgrimm

@mathiasgrimm mathiasgrimm commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up fixes for the review findings on #22 (excluding the breaking-change changelog item).

  • README: NETWATCH_PROBE_GOOGLE_DNS_WARN_MS is documented as 35, matching the config default (Add TCP probes, secure-by-default health route, and robust config defaults #22 changed the config but only updated the Cloudflare line in the README).
  • TCP probe config entries (config file and README example): use ?: instead of ?? for the host fallback, so a false return from parse_url() on malformed input still falls back to the raw env value. Ports use (int) (env(...) ?: default), so an empty DB_PORT/REDIS_PORT uses the default instead of port 0.
  • Database default port is connection-aware: when DB_PORT is not set, the database-tcp probe defaults by DB_CONNECTION (pgsql 5432, sqlsrv 1433, otherwise 3306) instead of always assuming MySQL.
  • TcpPingProbe: accepts a nullable host and returns a failing ProbeResult ("no host configured") instead of throwing a TypeError when the host env var is unset but the probe is enabled.
  • Authorize middleware: the token check requires a non-empty string before calling hash_equals(), so ?token[]=x gets a 403 instead of a TypeError (500).

Testing

  • vendor/bin/pint --test passes.
  • vendor/bin/pest: 132 passed (456 assertions), including 3 new regression tests for the null host, empty host, and array token cases.

🤖 Generated with Claude Code

mathiasgrimm and others added 2 commits July 16, 2026 21:19
- README: google-dns warn default is 35 ms, matching the config
- TCP probe config entries use ?: so a false return from parse_url
  still falls back to the raw env value, and empty port env values
  fall back to the default instead of port 0
- TcpPingProbe accepts a null/empty host and returns a failing
  ProbeResult instead of throwing a TypeError
- Authorize middleware ignores non-string token query params instead
  of letting hash_equals throw a TypeError (500)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3306 only applies to MySQL/MariaDB; pgsql defaults to 5432 and
sqlsrv to 1433 when DB_PORT is not set.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mathiasgrimm
mathiasgrimm merged commit 3667725 into main Jul 17, 2026
4 checks passed
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