Skip to content

fix(cli): decode the server's code page in errors - #27

Merged
mrcsin merged 1 commit into
masterfrom
decode-server-errors
Oct 28, 2026
Merged

mrcsin merged 1 commit into
masterfrom
decode-server-errors

Conversation

@mrcsin

@mrcsin mrcsin commented Oct 28, 2026

Copy link
Copy Markdown
Member

Problem

A PostgreSQL with Russian lc_messages reports a failed login before the client encoding applies, so its text arrives in CP1251 inside an otherwise UTF-8 error. semibase printed the bytes as they came, and the site log Setup writes showed replacement characters where the reason should be:

failed SASL auth: �����: ������������ "postgres" �� ������ �������� �����������

Change

  • cmd/semibase/text.go: readableText re-decodes each non-ASCII run of an error line that is not valid UTF-8; ASCII and valid UTF-8 pass unchanged, so an English server is unaffected.
  • cmd/semibase/text_windows.go: the decoder is the Windows ANSI code page (GetACP + MultiByteToWideChar); other platforms keep the bytes.
  • main.go applies it to the error: line of site and bench; docs/architecture/installer.md states it beside the SitePasswordWrong rule.

Verification

  • go test ./... (TestReadableText, and TestDecodeCodePage with the real CP1251 bytes), golangci-lint run: 0 issues.
  • Live, on a PostgreSQL 17 with Russian lc_messages: SEMIBASE_SUPER_PASSWORD=<wrong> semibase bench now writes failed SASL auth: ВАЖНО: пользователь "postgres" не прошёл проверку подлинности (по паролю) (SQLSTATE 28P01).

🤖 Generated with Claude Code

A PostgreSQL with Russian lc_messages reports a failed login before
the client encoding applies, so its text arrives in CP1251 inside an
otherwise UTF-8 error. semibase printed the bytes as they came, and
the site log Setup writes showed replacement characters where the
reason should be.

The error line now re-decodes each non-ASCII run that is not valid
UTF-8 from the Windows ANSI code page; ASCII and valid UTF-8 pass
unchanged, so an English server is unaffected.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mrcsin
mrcsin force-pushed the decode-server-errors branch from fdb4e88 to 1d49a63 Compare October 28, 2026 08:47
@mrcsin
mrcsin marked this pull request as ready for review October 28, 2026 08:47
@mrcsin
mrcsin merged commit b630df5 into master Oct 28, 2026
3 checks passed
@mrcsin
mrcsin deleted the decode-server-errors branch October 28, 2026 08:54
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