Skip to content

37463 跟进:服务器 5xx 故障日志不打印被包装的原始错误(cause) #37598

Done
2 of 2 issues completed

Description

@objectstack-fleet

repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

Filing gate: ② follow-up out of #37463. The source is the os-dev rework report on PR #37550 (comment 7195114149, out-of-scope finding, class a). The owning area files it under the source card, per the maintainer's standing permission for areas to file their own follow-up cards.
Grading: area:ai · Bug · p2 · reach: every operator reading a 5xx fault line from a producer that wraps a driver error on cause (record-context outages on both MCP doors; any other wrapper) · evidence: measured (real-kernel harness, packages/runtime/src/mcp-record-context-tools-bridge.test.ts, before PR #37550's stack suffix).

维护者速读

  • 做什么:服务器记录 5xx 故障日志时,只打印外层错误的信息和堆栈,不打印它包着的原始错误(cause)。运维看日志时找不到真正的故障原因。让故障日志把原始错误一起打出来。
  • 谁受益:排障的运维和开发。
  • 不做会怎样:每个把底层错误包一层再抛出的地方,日志里都丢了根因;各处只能各自把原因拼进堆栈来绕开。
  • 需要你做的:无。

What

  • packages/types/src/server-fault-log.ts#logServerFault prints console.error(message, { ...meta, stack }) and logger.error(message, err, meta).
  • packages/core/src/logger.ts write() serializes an error as { message, stack }.
  • Neither reads Error.cause, so a 5xx thrown with the original on cause logs without it. PR fix(record-context): a related object's read that fails is a failure, not a refusal #37550 worked around this for record-context by appending Caused by: and the original's stack to the failure's own stack.
  1. Print the cause chain in both sinks: message and stack of each cause, bounded in depth, and never on the wire (the fault log is operator-only).
  2. Then drop the record-context stack suffix of PR fix(record-context): a related object's read that fails is a failure, not a refusal #37550, so there is one place that renders a cause.

Acceptance

  • A test per sink: a 5xx with a nested cause logs each cause's message and stack; a cycle or a deep chain is bounded.
  • The record-context harness outage case still finds the original in the fault line after the suffix is removed.
  • No change to any response body.
  • Clause-②: no, Metadata-protocol: none.

Parent: #37463
Size: S
Dedupe (objectstack, is:issue): logServerFault cause 0 · fault log Error.cause 0 · ObjectLogger cause dropped 0.

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    priority:p2
    pm:queue
    area:ai
    domain:server
    on Nov 26, 2026
  2. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:ai · domain:server · Bug · priority:p2 · pm:queue · size S; rationale: server 5xx fault logs do not print the wrapped original error (cause), so operators cannot see the real fault. Measured; p2 as filed.

  3. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

    Claim: PM loop round 11 · area ai-36996 (topic #36996 non-cloud rows; the maintainer, verbatim, 2026-11-25T12:57Z project thread: 「开一个 36996 专题,接手剩余任务」; area concurrency 3 under the maintainer's total of 10, 2026-11-26T13:44Z: 「后续并发降到10」) · 2026-11-26T16:54Z
    Session: session_01Utp6CbeF2saT6wUBV4E9uc
    Account: os-bill
    Area: ai-36996
    Branch: claude/project-thread-w4acnx
    Thread session: session_01Utp6CZHczeF42DiDgkJPmk
    Domain: domain:server
    Seat: repo:objectstack#5
    File surface: packages/types/src/server-fault-log.ts (logServerFault), packages/core/src/logger.ts (ObjectLogger.write) and their tests; packages/services/service-record-context/src/record-context-tools.ts (remove the Caused by: stack suffix, line 495 on main) and the harness pin in packages/runtime/src/mcp-record-context-tools-bridge.test.ts that reads the fault line; root .changeset/. ⛔ No packages/spec/**, skills/**, docs/adr/**, ui/**; no response body changes. Stop on breach and report.
    Container & model: S, mode:thread, model: default — dispatch-gates --tier: "no path-derived mandate"; the thread serves claude-opus-5-5, effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: packages/types (logServerFault) and packages/core (ObjectLogger.write) produce the lost root cause | no platform path covers it | every operator reading a 5xx fault line from a producer that wraps an error on cause
    Premise: holds — on origin/main 3806b2e46a: PR #37550 merged; record-context-tools.ts:495 appends Caused by: to the failure's stack because neither sink reads Error.cause.
    Serial constraints cleared: #37463 (PR #37550) merged. Siblings #37141 (PR #37552: spec, mcp, lint, runtime domains/mcp.ts) and #37562 (ui/**): disjoint.
    Pre-claim deps: #37463 closed
    Prior rulings read: seat REWORK 7193191377 (M1) and delta records 7195224182, 7197072679 on PR #37550; os-dev report 7195114149 (finding)

  4. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 26, 2026
  5. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CZHczeF42DiDgkJPmk
    os-dev-report

    {
      "issue": 37598,
      "status": "done",
      "branch": "claude/project-thread-w4acnx",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37652",
      "head": "d12137d7ca7f0505e2b766db7dfd7563b80b4ddd",
      "session": "session_01Utp6CZHczeF42DiDgkJPmk",
      "premise_still_valid": true,
      "summary": "logServerFault (packages/types) now prints the thrown value's cause chain as `causes` beside `stack` on its console fallback, via a new exported faultCauseChain (outermost first, each link message + stack, bounded at FAULT_CAUSE_DEPTH_LIMIT = 5 links, cycle-safe, each cut ending in a marker link). ObjectLogger.write (packages/core) records an error as { message, stack, causes? } with the same bounds and shape. Two copies, pinned to one output by a parity test: core's ./logger entry is browser-safe and bundled by @objectstack/client, which does not depend on @objectstack/types, so importing it would pull the types root and its spec value imports into the browser logger. record-context-tools.ts drops the PR #37550 `Caused by:` stack suffix and its now-unused describeThrown. No response body changes.",
      "acceptance": [
        "a test per sink, nested cause logs each message and stack, cycle and deep chain bounded: packages/types/src/server-fault-log-cause.test.ts (10), packages/core/src/logger-error-cause.test.ts (10, incl. 5-fixture parity with faultCauseChain) — pass",
        "record-context harness outage case finds the original in the fault line with the suffix removed: packages/runtime/src/mcp-record-context-tools-bridge.test.ts asserts causes[0].message === `Error: OUTAGE` on all 4 fault lines and no `Caused by:` in stack — pass (28/28)",
        "no response body change: harness asserts both doors' answer text carries no cause text; sendServerFault case asserts the envelope is the generic one — pass",
        "Clause-②: no, Metadata-protocol: none — copied to PR body and changeset"
      ],
      "tests": "head d12137d7. Whole suites: @objectstack/types 42 files / 953 tests pass (on 0359bbfd; d12137d7 changes only server-fault-log-cause.test.ts, re-run 10/10 + typecheck exit 0); @objectstack/core 158 / 3774 pass, typecheck exit 0; @objectstack/service-record-context 4 / 174 pass, typecheck exit 0; @objectstack/runtime 650 files / 12074 pass, 25 skipped; runtime typecheck: tsc exit 0, check:test-typecheck 3 problems all TS2307 `@objectstack/driver-turso` not built locally in 3 untouched files (environment; CI TypeScript Type Check success). Ablation: the console branch's causes spread disabled via ablation-replace, types rebuilt, dist preflight marker present: server-fault-log-cause.test.ts 2 failed / 8 passed, runtime harness outage case failed (causes[0].message undefined); restored blob == HEAD, git diff HEAD empty, rebuilt, preflight --absent ok: 10/10 and 28/28. First ablation attempt was void (mutation left `causes` unused, types build failed TS6133 before preflight) and is not counted.",
      "gates": "local: dispatch-gates --commands on 0359bbfd derived 72 commands; 70 run: 68 exit 0; 2 exit 3 PREREQUISITE NOT MET = NOT MEASURED (check-plugin-teardown-shape --self-test needs an unshallow clone; check:dual-build-cjs-loads needs a full workspace build); 1 NOT MEASURED (check:type-check-debt killed at the background time limit); check-commit-card-trailers --range origin/main..HEAD pass; overlap-check VERDICT clean before both pushes. CI on d12137d7: 68 check-runs, 57 success, 11 skipped, 0 failure — incl. TypeScript Type Check, Lint & Repo Gates, Check Changeset, Build Core, Test Core (10/10 shards + aggregate), Test UI shards, Dogfood Regression Gate. The 0359bbfd run's three red aggregates were lanes cancelled by the d12137d7 push.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "files_changed": [".changeset/37598-fault-log-cause-chain.md", "packages/core/src/logger.ts", "packages/core/src/logger-error-cause.test.ts", "packages/types/src/server-fault-log.ts", "packages/types/src/server-fault-log-cause.test.ts", "packages/services/service-record-context/src/record-context-tools.ts", "packages/services/service-record-context/src/__tests__/record-context-tools.test.ts", "packages/runtime/src/mcp-record-context-tools-bridge.test.ts"],
      "line_budget": "+446 / -24 over 8 files (under the 3000 human-merge threshold)",
      "deviations": [
        "worked in the platform-designated checkout on the card-thread branch, not a separate worktree (mode:thread)",
        "no review request at draft open: the fleet's pr_create summons nobody; hand-off is the seat's",
        "check:type-check-debt not measured locally (time limit); CI TypeScript Type Check success"
      ],
      "mcp_calls": "0 GitHub MCP calls",
      "api_writes": "2 — relay pr_create (POST /repos/objectstack-ai/objectstack/pulls + POST /issues/37652/assignees), this os-dev-report comment (POST /issues/37598/comments)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": ["carrier: none · noted, not filed — @objectstack/observability ConsoleLogger / JsonLogger (loggers.ts lines 56, 114) record an error as { error, stack } without its cause; outside the claim's surface, reach not measured"]
    }

    Generated by Claude Code

  6. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CZHczeF42DiDgkJPmk
    os-dev-report

    {
      "issue": 37598,
      "status": "done",
      "round": "rework for contract review 7200020944 (FAIL) and seat REWORK 7200035097",
      "branch": "claude/project-thread-w4acnx",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37652",
      "head": "5a623151013b8fc71ea913cdbec0a727be96cdd7",
      "previous_head": "d12137d7ca7f0505e2b766db7dfd7563b80b4ddd",
      "session": "session_01Utp6CZHczeF42DiDgkJPmk",
      "premise_still_valid": true,
      "summary": "M1: Clause-② now reads `yes (widening)` in the PR body and the changeset; every package stays at patch. S1: fixed as the area relayed, in both copies; pinned by the tests under `a cause is redacted like the error` in both packages. S2: each link is read inside a guard in both copies; a link whose name, message or stack read throws ends the chain in the marker `[cause chain link unreadable: reading it threw]` and the line / record is still written. faultCauseChain's second parameter is now the per-key predicate (the depth stays FAULT_CAUSE_DEPTH_LIMIT). S3: PR body and this report name #37658. N1: both docblocks name logger-error-cause.test.ts. Surface unchanged (same 8 files).",
      "acceptance": [
        "M1: PR body line 4 and .changeset/37598-fault-log-cause-chain.md read `Clause-②: yes (widening)`; Check Changeset success on 5a623151",
        "S1: packages/types/src/server-fault-log-cause.test.ts and packages/core/src/logger-error-cause.test.ts `a cause is redacted like the error` — pass",
        "S2: per-package cases (message getter throws ⇒ marker, line/record written) plus four new parity fixtures (a cause redacted like the error, an object cause that cannot be serialized, a link whose message read throws, a throwing cause getter) — pass; parity now 9 fixtures",
        "S3: carrier #37658 in the PR body's Acceptance notes and below",
        "N1: docblocks in server-fault-log.ts and logger.ts name logger-error-cause.test.ts"
      ],
      "tests": "@objectstack/types whole suite 42 files / 956 pass, typecheck exit 0; @objectstack/core whole suite 158 / 3780 pass, typecheck exit 0; @objectstack/service-record-context 4 / 174 pass; runtime harness mcp-record-context-tools-bridge.test.ts 28/28 (on rebuilt types/core dist). The last commit only renamed test cases: server-fault-log-cause.test.ts 13/13, logger-error-cause.test.ts 16/16 on 5a623151.",
      "gates": "dispatch-gates --commands derives the same 72 families as round 1 (diffed); not re-run locally this round beyond the targeted suites — CI on 5a623151: 72 check-runs, 59 success, 13 skipped, 0 failure (TypeScript Type Check, Lint & Repo Gates, Check Changeset, Test Core, Test UI success). The 1174c130 run's three red aggregates were lanes cancelled by the 5a623151 push. check-commit-card-trailers and overlap-check clean before each push.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "files_changed": [".changeset/37598-fault-log-cause-chain.md", "packages/core/src/logger.ts", "packages/core/src/logger-error-cause.test.ts", "packages/types/src/server-fault-log.ts", "packages/types/src/server-fault-log-cause.test.ts", "packages/services/service-record-context/src/record-context-tools.ts", "packages/services/service-record-context/src/__tests__/record-context-tools.test.ts", "packages/runtime/src/mcp-record-context-tools-bridge.test.ts"],
      "line_budget": "+583 / -24 over 8 files (under the 3000 human-merge threshold)",
      "deviations": ["no new ablation this round (the dispatch asked for one, done in round 1 on the cause printing)"],
      "mcp_calls": "0 GitHub MCP calls",
      "api_writes": "2 this round — relay issue_patch (PATCH /issues/37652, PR body), this report (POST /issues/37598/comments)",
      "open_questions": [],
      "security_findings": "withheld",
      "out_of_scope_findings": ["carrier: #37658 — @objectstack/observability ConsoleLogger / JsonLogger record an error without its cause"]
    }

    Generated by Claude Code

  7. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CZHczeF42DiDgkJPmk
    os-dev-report

    {
      "issue": 37598,
      "status": "done",
      "round": "second delta for contract review 7200840843 (PASS) and seat REWORK 7200856706",
      "branch": "claude/project-thread-w4acnx",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37652",
      "head": "d6092ff79df63ec50fcaa457ca84d2787029f838",
      "previous_head": "5a623151013b8fc71ea913cdbec0a727be96cdd7",
      "session": "session_01Utp6CZHczeF42DiDgkJPmk",
      "premise_still_valid": true,
      "summary": "S4: faultCauseChain's default field-name rule is now ObjectLogger's whole-word matcher (tokenizeFieldName / fieldWordsMatchPattern and its helpers, the #5573 rule) over LoggerConfig.redact's default words, copied beside it in server-fault-log.ts; the substring match is gone. N2: the faultCauseChain docblock states the fallback applies only the default words, never a host's own redact list. N3: an array inside an object cause is pinned in both packages and in the parity fixtures. Surface unchanged (same 8 files).",
      "acceptance": [
        "S4: core parity fixture `field names under the default redact words, whole-word matched` (keys, tokens, monkey, keyword, secretary, tokenizer, apiKey, apikey, accesstoken, refresh_tokens, clientSecret, password, API_KEY) — pass; types case `by whole words, as the logger matches its redact list` — pass",
        "S4 drift check: types fallback put back to a substring match via ablation-replace, types rebuilt: that parity fixture failed (1 failed / 17 passed); restored blob == HEAD, git diff HEAD empty, rebuilt, preflight --absent ok: 18/18",
        "N2: docblock sentence starting `Only the default words` in server-fault-log.ts",
        "N3: types case `inside an array in an object cause` and core parity fixture `an array inside an object cause` — pass"
      ],
      "tests": "@objectstack/types whole suite 42 files / 958 pass, typecheck exit 0; @objectstack/core typecheck exit 0, logger-error-cause.test.ts + logger.test.ts 106 pass (logger-error-cause 18/18 after restore); runtime harness mcp-record-context-tools-bridge.test.ts 28/28 on the rebuilt types dist.",
      "gates": "CI on d6092ff7: 72 check-runs, 58 success, 13 skipped, 1 cancelled (PR-body guards 140113549483, superseded by its rerun 140113809653 success after the body patch); TypeScript Type Check, Lint & Repo Gates, Check Changeset, Test Core, Test UI success. check-commit-card-trailers and overlap-check clean before the push.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "files_changed": [".changeset/37598-fault-log-cause-chain.md", "packages/core/src/logger.ts", "packages/core/src/logger-error-cause.test.ts", "packages/types/src/server-fault-log.ts", "packages/types/src/server-fault-log-cause.test.ts", "packages/services/service-record-context/src/record-context-tools.ts", "packages/services/service-record-context/src/__tests__/record-context-tools.test.ts", "packages/runtime/src/mcp-record-context-tools-bridge.test.ts"],
      "line_budget": "+683 / -24 over 8 files (under the 3000 human-merge threshold)",
      "deviations": [],
      "mcp_calls": "0 GitHub MCP calls",
      "api_writes": "2 this round — relay issue_patch (PATCH /issues/37652, PR body), this report (POST /issues/37598/comments)",
      "open_questions": [],
      "security_findings": "withheld",
      "out_of_scope_findings": ["carrier: #37658 — @objectstack/observability ConsoleLogger / JsonLogger record an error without its cause", "carrier: area — the MCP doors log through the console fallback rather than the kernel logger (seat REWORK 7200856706 item 5)"]
    }

    Generated by Claude Code

  8. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

    ACCEPT → PR #37652 comment 7201440400

  9. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

    Merged: PR #37652 at 6b7b3051c1 closed this card by Fixes. Delivered: the fault log and ObjectLogger print the full cause chain, so a wrapped failure shows its root error. Left: #37658 (observability loggers, plus N4: the rest of the glued qualifiers in the parity fixture) and #37666 (MCP doors get the kernel logger), both unblocked now. pm:dispatched removed.

  10. removed
    pm:dispatched
    on Nov 26, 2026
  11. added a commit that references this issue on Dec 1, 2026
    6b7b305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:serverpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions