Skip to content

fix(bigtable): encode str qualifier in DeleteRangeFromColumn and allow -2**63 in int mutations - #18881

Merged
mutianf merged 3 commits into
mainfrom
fix-mutation-validation
Oct 30, 2026
Merged

mutianf merged 3 commits into
mainfrom
fix-mutation-validation

Conversation

@mutianf

@mutianf mutianf commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • DeleteRangeFromColumn qualifier validation and encoding: DeleteRangeFromColumn did not encode str qualifiers to bytes in __post_init__, causing proto-plus to treat string qualifiers as base64 during _to_pb() serialization and either silently decode into the wrong column bytes or fail with binascii.Error. __post_init__ now encodes str qualifiers to UTF-8 bytes and raises TypeError for non-bytes/str inputs, matching SetCell and AddToCell.
  • Allow -2**63 (INT64_MIN) in integer mutations and increment rules: SetCell, AddToCell, and IncrementRule checked abs(val) > (1 << 63) - 1, which rejected the valid two's-complement minimum 64-bit signed integer -2**63 (-9223372036854775808) with ValueError. Replaced the abs() check with _MIN_INCREMENT_VALUE <= val <= _MAX_INCREMENT_VALUE.

Test plan

  • Added unit tests in tests/unit/data/test_mutations.py and tests/unit/data/test_read_modify_write_rules.py covering -2**63 and 2**63 - 1 bounds and DeleteRangeFromColumn str / invalid qualifier handling.

@mutianf
mutianf requested a review from a team as a code owner October 28, 2026 15:22

@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 updates integer boundary checks across mutations and read-modify-write rules to correctly validate 64-bit signed integers using both minimum and maximum bounds, and adds support for string qualifiers in DeleteRangeFromColumn. The review feedback correctly points out that several error messages incorrectly state the upper limit as 263 instead of the exclusive 263 - 1, and suggests updating these messages to prevent user confusion.

@mutianf
mutianf force-pushed the fix-mutation-validation branch from e251888 to a8364ea Compare October 28, 2026 19:30
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 29, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 29, 2026
@mutianf
mutianf force-pushed the fix-mutation-validation branch from a8364ea to 4aed324 Compare October 30, 2026 02:49
@mutianf
mutianf merged commit 6e80b83 into main Oct 30, 2026
57 checks passed
@mutianf
mutianf deleted the fix-mutation-validation branch October 30, 2026 19:54
daniel-sanche pushed a commit that referenced this pull request Oct 30, 2026
…w -2**63 in int mutations (#18881)

## Summary

- **`DeleteRangeFromColumn` qualifier validation and encoding**:
`DeleteRangeFromColumn` did not encode `str` qualifiers to `bytes` in
`__post_init__`, causing `proto-plus` to treat string qualifiers as
base64 during `_to_pb()` serialization and either silently decode into
the wrong column bytes or fail with `binascii.Error`. `__post_init__`
now encodes `str` qualifiers to UTF-8 `bytes` and raises `TypeError` for
non-`bytes`/`str` inputs, matching `SetCell` and `AddToCell`.
- **Allow `-2**63` (`INT64_MIN`) in integer mutations and increment
rules**: `SetCell`, `AddToCell`, and `IncrementRule` checked `abs(val) >
(1 << 63) - 1`, which rejected the valid two's-complement minimum 64-bit
signed integer `-2**63` (`-9223372036854775808`) with `ValueError`.
Replaced the `abs()` check with `_MIN_INCREMENT_VALUE <= val <=
_MAX_INCREMENT_VALUE`.

## Test plan

- [x] Added unit tests in `tests/unit/data/test_mutations.py` and
`tests/unit/data/test_read_modify_write_rules.py` covering `-2**63` and
`2**63 - 1` bounds and `DeleteRangeFromColumn` `str` / invalid qualifier
handling.
daniel-sanche pushed a commit that referenced this pull request Dec 3, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.51.0](google-cloud-bigtable-v2.50.2...google-cloud-bigtable-v2.51.0)
(2026-12-03)


### Features

* update API sources and regenerate
([#19310](#19310))
([28423cb](28423cb))


### Bug Fixes

* **bigtable:** encode prefix to UTF-8 bytes before computing upper
bound in RowSet.add_row_range_with_prefix
([#18954](#18954))
([dfd9606](dfd9606))
* **bigtable:** encode str qualifier in DeleteRangeFromColumn and allow
-2**63 in int mutations
([#18881](#18881))
([6e80b83](6e80b83))
* **bigtable:** Log warning on background task failure instead of
exception
([#18193](#18193))
([92a8bf4](92a8bf4))
* **bigtable:** pack unpacked error details in _get_status and harden
batcher error handling
([#18770](#18770))
([525e740](525e740))
* **bigtable:** remove unneeded status field from throttling latencies
metric
([#18858](#18858))
([dd48193](dd48193))
* **bigtable:** restore the mutation lifecycle in mutate_rows and
DirectRow.commit
([#18856](#18856))
([d0ce8e3](d0ce8e3))
* **bigtable:** synchronize MutationsBatcher staging and flush
scheduling
([#18827](#18827))
([38afa8a](38afa8a))
* **bigtable:** validate DirectRow and table match in
MutationsBatcher.mutate
([#18874](#18874))
([8aa6d4d](8aa6d4d))
* **google-cloud-bigtable:** clamp mutate_row retry attempt timeouts to
remaining operation timeout
([#19017](#19017))
([304ffef](304ffef))


### Documentation

* **bigtable:** add async admin samples
([#18923](#18923))
([14fb90b](14fb90b))
* **bigtable:** add samples for sync client
([#17820](#17820))
([72e5f48](72e5f48))
* **bigtable:** authorized view samples
([#19082](#19082))
([a476483](a476483))
* **bigtable:** clarify that MutationsBatcher.flush defers exceptions to
close
([#18825](#18825))
([371218d](371218d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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.

3 participants