GumpacG opened a new pull request, #3539:
URL: https://github.com/apache/tinkerpop/pull/3539

   ## Summary
   
   `gremlin-python`'s GraphBinary `BigIntIO` writer computed the byte length 
from the
   value's magnitude bit-length but encoded the bytes as signed 
two's-complement. Negative
   boundary values (e.g. `-129`, `-255`) raised `OverflowError`, and 
positive/zero values
   produced non-canonical bytes that diverge from the Java reference 
(`BigInteger.toByteArray()`).
   
   The fix computes the minimal signed two's-complement length, unifying the 
positive, negative,
   and zero paths. `BigDecimal` is fixed transitively (its unscaled value is 
serialized as a
   `BigInteger`).
   
   ## Before vs After
   
   | Value | Before | After |
   |---|---|---|
   | `BigInteger(-129)` | `OverflowError` | `00 00 00 02 ff 7f` |
   | `BigDecimal(-2.55)` (unscaled `-255`) | `OverflowError` | `00 00 00 02 ff 
01` |
   | `BigInteger(127)` | `00 00 00 02 00 7f` (non-minimal) | `00 00 00 01 7f` |
   | `BigInteger(0)` | `00 00 00 00` (Java rejects) | `00 00 00 01 00` |
   
   ## Changes
   
   - `gremlin-python/.../structure/io/graphbinaryV1.py` - rewrote 
`BigIntIO.write_bigint`.
   - `gremlin-python/.../tests/unit/io/test_graphbinaryV1.py` - added boundary 
round-trip tests
     and exact wire-byte assertions.
   
   
   Assisted-by: Kiro:claude-opus-4.8


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to