Skip to content

fix(otel): omit empty joined exception stacks - #902

Open
LionStone-1 wants to merge 2 commits into
aws:mainfrom
LionStone-1:contribpilot/issue-886-empty-exception-stack
Open

LionStone-1 wants to merge 2 commits into
aws:mainfrom
LionStone-1:contribpilot/issue-886-empty-exception-stack

Conversation

@LionStone-1

Copy link
Copy Markdown

Issue #, if available

Closes #886.

Description of changes

#901 removed the synthetic carrier exception. One acceptance case remains: a stored stack of [""] is a truthy list, so the recorder still emits exception.stacktrace="".

Check the joined stack string before adding the attribute. Nonempty strings, including whitespace and newlines, remain unchanged. Core exception capture and checkpoint persistence are unchanged. Clarify this distinction in the OTel README.

Design

  • Design note: not needed; this is a bug fix with no new option or public API change.
  • Simpler options considered: use the existing newline join and test its result. No additional normalization, stack reconstruction or special-case branches are needed.
  • Root cause: the current condition checks list presence rather than whether the resulting stack string is nonempty.
  • Net change: +1 source line; no public API members added or removed. Tests and documentation add 46 lines net.

Assumptions

The behavior follows #886's explicit nonempty-joined-string requirement. Regression tests exercise both OTel plugins through operation/attempt lifecycle events, live and replayed, after an ErrorObject serialization round trip. Supplied whitespace/newlines, type/message, failure status and event timestamp bounds are checked. No deployed Lambda validation is claimed.

Decisions not covered by the issue or the design note

None; this implements the remaining [""] acceptance case without changing the issue's scope.

Validation

Python 3.14.8, Hatch 1.16.5:

  • Before source fix: new regression 7 failed, 41 passed.
  • After fix: new regression 48 passed.
  • hatch run dev-otel:test -q: 968 passed (73 warnings).
  • hatch run dev-otel:typecheck: passed, 46 source files.
  • hatch fmt --check from the OTel package: passed.
  • Core and OTel sdists/wheels built; hatch run test-wheel-otel:test -q: 968 OTel tests and 12 compatibility tests passed.
  • git diff --check: passed.

Checklist

  • Every new branch has a regression that fails without the fix.
  • The first commit adds the failing regression; the second contains the source fix and documentation.
  • No existing test expectations changed.

Prepared with Codex assistance; tests and package checks were executed locally.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@LionStone-1
LionStone-1 marked this pull request as ready for review November 3, 2026 06:16
@LionStone-1
LionStone-1 deployed to ai-pr-review-runtime November 3, 2026 06:16 — with GitHub Actions Active
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Codex AI review

No actionable findings after reviewing all changes against CONTRIBUTING.md rules 1–9. Tests were inspected but not executed under the read-only review constraints; reported test results were not independently verified.

Reviewed commit 85cb1fbadbffe1b9453245c81678a49eb41d7922. Workflow run

attributes["exception.message"] = error.message
if error.stack_trace:
attributes["exception.stacktrace"] = "\n".join(error.stack_trace)
stack_trace = "\n".join(error.stack_trace or [])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if stack_trace is malformed, e.g. ["frame", None]?

This branch was successfully deployed

1 active deployment
ai-pr-review-runtime — 85cb1fba Deployed Nov 3, 2026 by LionStone-1 via notify / Generate notification summary #373
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.

[Bug]: Align OTel exception stacktrace emission with OpenTelemetry JS

2 participants