Стабильные detail для 4xx (store, CDN preview, CSV); логирование на сервере. Расширен lint-httpapi для ERR-01 в 4xx. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.1 KiB
Bash
37 lines
1.1 KiB
Bash
#!/usr/bin/env sh
|
|
# Engineering gates for internal/httpapi (ERR-01, ARCH-01).
|
|
set -eu
|
|
|
|
ROOT="$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
HTTPAPI="internal/httpapi"
|
|
FAIL=0
|
|
|
|
echo "==> ERR-01: no err.Error() in 5xx problem details"
|
|
if grep -rE 'writeProblem\(w, http\.StatusInternalServerError.*err\.Error\(\)' "$HTTPAPI" 2>/dev/null; then
|
|
FAIL=1
|
|
fi
|
|
if grep -rE 'writeProblem\(w, http\.StatusBadGateway.*err\.Error\(\)' "$HTTPAPI" 2>/dev/null; then
|
|
FAIL=1
|
|
fi
|
|
|
|
echo "==> ERR-01: no err.Error() in 4xx writeProblem (store/cdn/csv)"
|
|
if grep -rE 'writeProblem\(w, http\.Status(NotFound|UnprocessableEntity|BadRequest).*, err\.Error\(\)' "$HTTPAPI" 2>/dev/null; then
|
|
FAIL=1
|
|
fi
|
|
if grep -rE 'writeStoreErr.*err\.Error|writeProblem.*Unprocessable.*err\.Error' "$HTTPAPI" 2>/dev/null; then
|
|
FAIL=1
|
|
fi
|
|
|
|
echo "==> ARCH-01: no SQL/pgx queries in httpapi"
|
|
if grep -rE 'pool\.(Query|Exec|QueryRow)|SELECT |INSERT INTO |UPDATE .* SET |DELETE FROM ' "$HTTPAPI" 2>/dev/null; then
|
|
FAIL=1
|
|
fi
|
|
|
|
if [ "$FAIL" -ne 0 ]; then
|
|
echo "lint-httpapi: failed" >&2
|
|
exit 1
|
|
fi
|
|
echo "lint-httpapi: ok"
|