Skip to content

Commit aafc277

Browse files
committed
docs: forbid err.Error() substring classification, document Windows errno gotcha
Codify the lesson from the connectex CI failure. syscall.ECONNREFUSED on Windows is APPLICATION_ERROR + iota, NOT the WSA error code that net/http surfaces, so errors.Is against the standard syscall.Errno sentinels always returns false. The fix is build-tagged sentinel lists that use golang.org/x/sys/windows.WSA* on Windows; see internal/llm/network_errors_{windows,other}.go for the pattern.
1 parent fcadc82 commit aafc277

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,19 @@ details; do not duplicate that detail here.
344344
(e.g. `delete(m, "id"); delete(m, "ID")`) -- that papers over an
345345
inconsistency instead of fixing it. If you see ambiguity, fix the
346346
source struct's tags.
347+
- **No string matching to classify errors**: Never inspect `err.Error()`
348+
substrings to decide whether an error is e.g. a network failure or a
349+
syntax error. Substring checks break silently when an upstream wrapper
350+
changes its message format. Use `errors.Is` against typed sentinels or
351+
`errors.As` against typed error structs. **Windows socket gotcha**:
352+
`syscall.ECONNREFUSED`/`ENETUNREACH`/`EHOSTUNREACH` are NOT portable.
353+
On Windows they are `APPLICATION_ERROR | iota` invented constants that
354+
never match the WSA error codes (10061/10051/10065) `net/http` actually
355+
returns -- so `errors.Is(err, syscall.ECONNREFUSED)` always fails on
356+
Windows. Define platform-specific sentinel lists in build-tagged files
357+
using `golang.org/x/sys/windows.WSA*` (already typed as `syscall.Errno`)
358+
for the Windows variant. See `internal/llm/network_errors_{windows,other}.go`
359+
for the pattern.
347360
- **Deterministic ordering requires tiebreakers**: Every `ORDER BY` that
348361
could tie MUST include a tiebreaker (typically `id DESC`).
349362
- **Audit new deps before adding**: Review source for security issues

0 commit comments

Comments
 (0)