Skip to content

fix(bigtable): avoid self-referential error on RPC-level mutate failure#8823

Open
kyungseopk1m wants to merge 2 commits into
googleapis:mainfrom
kyungseopk1m:fix/bigtable-mutate-self-referential-error
Open

fix(bigtable): avoid self-referential error on RPC-level mutate failure#8823
kyungseopk1m wants to merge 2 commits into
googleapis:mainfrom
kyungseopk1m:fix/bigtable-mutate-self-referential-error

Conversation

@kyungseopk1m

Copy link
Copy Markdown

When Table#mutate / Table#insert hits an RPC-level failure with entries still pending and no per-entry mutation errors, mutateInternal set err.errors to an array containing err itself. The resulting cycle (err.errors[i] === err) makes the error impossible to serialize with anything that follows the AggregateError convention of recursing into errors — for example pino, which throws RangeError: Maximum call stack size exceeded.

This pushes a fresh error carrying the RPC-level code and message for each pending entry instead of err itself. The errors array is only consumed for its per-entry code/message (the existing Table#mutate error tests and the callback.err.errors docs), so nothing relies on the former self-reference.

The existing "not retryable" test already exercises this branch (an index-0 success followed by a stream error); it now also asserts that err.errors[0] is not err and that the resulting error can be serialized.

  • Make sure to open an issue as a bug before writing your code, and reference it in your PR.
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #8075 🦕

When mutate hits an RPC-level failure with entries still pending and no
per-entry mutation errors, mutateInternal set err.errors to an array
containing err itself. The resulting cycle (err.errors[i] === err) makes the
error impossible to serialize with tools that follow the AggregateError
convention of recursing into errors, such as pino, which throws
RangeError: Maximum call stack size exceeded.

Push a fresh error carrying the RPC-level code and message for each pending
entry instead of err itself.

Fixes googleapis#8075
@kyungseopk1m kyungseopk1m requested a review from a team as a code owner July 7, 2026 06:18
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Jul 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request resolves a serialization issue in mutateInternal.ts where a self-referencing error was created by pushing the parent RPC error into its own errors array. It fixes this by creating a fresh entryError with the copied message and code, and adds a corresponding regression test. The reviewer suggested also copying metadata and details from the original RPC error to preserve debugging context.

Comment thread handwritten/bigtable/src/utils/mutateInternal.ts
… error

The fix for googleapis#8075 replaced the self-referential error with a fresh error
carrying only the RPC-level code and message. The former self-reference also
exposed the metadata and details of the gRPC failure on each entry error;
restore that debugging context on the fresh error so downstream consumers do
not lose it. The regression test now seeds a non-empty metadata and details on
the failure and asserts both are carried through.

Fixes googleapis#8075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bigtable: mutateInternal builds self-referential error (err.errors contains err) — breaks pino / AggregateError-aware serializers

1 participant