Skip to content

The type google.protobuf.timestamp.Timestamp may have a bug when used as part of generated Python protobuf library #21541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
edward-bestx opened this issue Apr 30, 2025 · 1 comment
Assignees
Labels
untriaged auto added to all issues by default when created.

Comments

@edward-bestx
Copy link

What version of protobuf and what language are you using?

$ protoc --version
libprotoc 3.21.12

Language: Python

$ ~/venv/bin/python3 --version
Python 3.12.7

What operating system (Linux, Windows, ...) and version?

WSL via Windows 11. This is Ubuntu 24.10.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.10
Release:        24.10
Codename:       oracular

What runtime / compiler are you using (e.g., python version or gcc version)

$ ~/venv/bin/python3 --version
Python 3.12.7

What did you do?
Steps to reproduce the behavior:

I'm not really sure what is going on. I have tried two ways to create a protobuf object which contains a repeated google.protobuf.timestamp.Timestamp type.

Here is my .proto file.

syntax = "proto3";

import "google/protobuf/timestamp.proto"

message BidAskTimeseries {
    repeated double bid = 1;
    repeated double ask = 2;
    repeated google.protobuf.Timestamp timestamp = 3;
}

The two methods I tried are:

  1. Using constructor
  2. Using the .extend method of a "repeated scalar container"

Example 1:

import bid_ask_timeseries_pb2

bid_ask_timeseries = bid_ask_timeseries_pb2.BidAskTimeseries(
    bid=bid,
    ask=ask,
    timestamp=timestamp,
)

Example 2:

import bid_ask_timeseries_pb2

bid_ask_timeseries = bid_ask_timeseries_pb2.BidAskTimeseries()
bid_ask_timeseries.bid.extend(bid)
bid_ask_timeseries.ask.extend(ask)
bid_ask_timeseries.timestamp.extend(timestamp)

In both cases, the objects bid, ask and timestamp are numpy.array types containing floating point values (for bid and ask) or datetime.datetimes (for timestamp).

I see the following error in both cases:

TypeError: 'Timestamp' object cannot be interpreted as an integer

I don't understand this error message. It reads as if the type BidAskTimeseries is expecting integer type for the field timestamp instead of a datetime.

I'm not sure if this is a red herring however, since it doesn't seem to make any sense.

@edward-bestx edward-bestx added the untriaged auto added to all issues by default when created. label Apr 30, 2025
@anandolee
Copy link
Contributor

We haven't add construction/extend support for repeated Timestamp/Duration yet. But we will add the support in the near future (this year)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged auto added to all issues by default when created.
Projects
None yet
Development

No branches or pull requests

2 participants