frequenz-floss / frequenz-api-weather

gRPC+protobuf specification and Python bindings for the Frequenz Weather API
MIT License
0 stars 8 forks source link

Error messages not informative #84

Closed david-natingga-frequenz closed 7 months ago

david-natingga-frequenz commented 7 months ago

What happened?

I made a sample query to the Weather API server and I got the following error message:

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.CANCELLED
    details = "Received RST_STREAM with error code 8"
    debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Received RST_STREAM with error code 8", grpc_status:1, created_time:"2024-02-28T13:49:48.559178078+01:00"}"

This is not very informative. For example why was the streaming cancelled/closed? In general we should have more informative error messages to facilitate more efficient debugging. This is especially true if the Weather API should be used by external parties.

What did you expect instead?

The error message should tell me the exact problem.

Affected version(s)

No response

Affected part(s)

I don't know (part:❓)

Extra information

No response

shsms commented 7 months ago

Could you please share a reproducible example?

david-natingga-frequenz commented 7 months ago

The following code if run from the root of the repository can reproduce the error:

import grpc
import datetime
from google.protobuf import timestamp_pb2
from frequenz.api.weather import weather_pb2_grpc, weather_pb2
from frequenz.api.common.pagination import pagination_params_pb2

svc_addr = 'localhost:50051'

def get_historical_weather_forecast():
    channel = grpc.insecure_channel(svc_addr)
    stub = weather_pb2_grpc.WeatherForecastServiceStub(channel)

    now = datetime.datetime.utcnow()
    start_ts = timestamp_pb2.Timestamp()
    start_ts.FromDatetime(now)
    end_ts = timestamp_pb2.Timestamp()
    end_ts.FromDatetime(now)
    pagination_params = pagination_params_pb2.PaginationParams()

    request = weather_pb2.GetHistoricalWeatherForecastRequest(
        start_ts = start_ts,
        end_ts = end_ts,
        pagination_params = pagination_params
    )

    response = stub.GetHistoricalWeatherForecast(request)

    print("Response:", response)

if __name__ == '__main__':
    get_historical_weather_forecast()
shsms commented 7 months ago

After speaking with David, this is likely an issue on the server side and we decided to track it there.