Skip to content

feat(log): error_code - #94

Merged
HecFranco merged 3 commits into
mainfrom
feat/error-code
Nov 28, 2026
Merged

HecFranco merged 3 commits into
mainfrom
feat/error-code

Conversation

@HecFranco

@HecFranco HecFranco commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Adds an optional, nullable error_code column to the usage rows (outbound) holding the machine code a provider returns with a failed call, so "401" can be told apart from "wrong client secret" without storing the response body.

What

  • outbound.providers.<key>.error_code.paths (dotted paths or JSON pointers, max 8, read in order) and prefix (integers only). Applies only to status >= 400 with a JSON body of at most 16 KiB that the application consumes; otherwise NULL.
  • Opt-in schema: the column and the index idx_http_log_errcode_created are mapped (like path_prefix) only while a provider sets error_code.paths. A host that does not configure it needs no migration; every reader and writer checks hasField('errorCode').
  • Allowlist: a token of A-Za-z0-9_.:- (1..64) that does not look like an identifier or a credential (digit runs of 10+, hex runs of 16+, mixed-case alphanumeric runs of 20+, IP addresses, values with 2+ dots, UUIDs, secret prefixes such as eyJ, sk_, ghp_, xox, AKIA, AIza); anything else is stored as unknown. At most 8 values / 128 bytes. The body, descriptions and ids are never stored. Re-validated on the Messenger payload and in CallQuery.
  • Admin list column, filter, entry detail, CSV/JSON export (errorCode, last), CallQuery::withErrorCode() (exact match), UsageCall::$errorCode; exact-match collation on MySQL/MariaDB; translations in 7 locales.
  • Worker mode: the body is buffered only in the per-call OutboundCall (closure-owned, cleared when the call is recorded).
  • Separate commit: the CSV export neutralises cells starting with =, +, -, @, TAB or CR (pre-existing; CHANGELOG "Security").

Not included

No correlation_id / upstream_id columns (no decided correlation-id contract).

Upgrade

Only when configuring error_code: migration or the per-platform SQL in docs/UPGRADING.md (Unreleased), pinned by UsageSchemaTest on SQLite, MySQL and PostgreSQL. A host overriding nowo_ui_list_row adds one cell (snippet in UPGRADING).

Per-provider outbound.providers.<key>.error_code (paths, prefix) stores the
allowlisted machine code of a failed call (status >= 400, JSON body of at most
16 KiB) in a new nullable error_code column. Shown, filterable and exported;
CallQuery::withErrorCode(). The body is never stored.
@github-actions

Copy link
Copy Markdown

@coderabbitai review

A text cell starting with =, +, -, @, TAB or CR is prefixed with an apostrophe
(OWASP). Affects the released versions that export CSV.
… the code allowlist

The column, index, admin fields and export column exist only while a provider
sets error_code.paths (no migration otherwise); every reader and writer checks
hasField. The allowlist rejects digit and hex runs, mixed-case keys, IP
addresses, host-like values and known secret prefixes. Exact matching for the
column, UPGRADING per-platform DDL and list-row override note.
@HecFranco
HecFranco marked this pull request as ready for review November 28, 2026 07:08
@HecFranco
HecFranco merged commit 058c9f9 into main Nov 28, 2026
21 of 22 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