Comments (6)
I think you need to create issue in https://github.com/memphisdev/memphis.py
from memphis.py.
Adding @shay23b to the rescue
from memphis.py.
Hey @yanivbh1 , i would love to work on this issue. Can you please tell me the file in which i should make the changes to make things work, because I have looked upon the code base, but i am unable to understand where this error message has been written.
from memphis.py.
Hi @Adarsh-jaiss ,
There are a few functions that raise "Unsupported message type" error in the producer.py file, in this case it returns from the "validate_protobuf" function
from memphis.py.
Hey @shay23b, @yanivbh1 , I tried to understand the bug and took help from an AI model and it suggested these changes in the "validate_protobuf" function :
In the updated code:
-
We added an additional
elif
condition to check if the message is of typedict
. Previously, onlybytearray
and objects withSerializeToString
method were supported. This will allow us to handle protobuf dictionaries as well. -
In the
else
block, we raise aMemphisSchemaError
with a more descriptive error message including the type of the unsupported message type.
By making these changes, the code will provide a clearer error message when encountering an unsupported message type. Additionally, it will be able to handle protobuf dictionaries as well.
Here's the updated code :
def validate_protobuf(self, message):
proto_msg = self.connection.proto_msgs[self.internal_station_name]
msg_to_send = ""
try:
if isinstance(message, bytearray):
msg_to_send = bytes(message)
try:
proto_msg.ParseFromString(msg_to_send)
proto_msg.SerializeToString()
msg_to_send = msg_to_send.decode("utf-8")
except Exception as e:
if "parsing message" in str(e):
e = "Invalid message format, expecting protobuf"
raise MemphisSchemaError(str(e))
return message
elif hasattr(message, "SerializeToString"):
msg_to_send = message.SerializeToString()
proto_msg.ParseFromString(msg_to_send)
proto_msg.SerializeToString()
try:
proto_msg.ParseFromString(msg_to_send)
proto_msg.SerializeToString()
except Exception as e:
if "parsing message" in str(e):
e = "Error parsing protobuf message"
raise MemphisSchemaError(str(e))
return msg_to_send
elif isinstance(message, dict):
try:
protobuf_json_format.ParseDict(message, proto_msg)
msg_to_send = proto_msg.SerializeToString()
return msg_to_send
except Exception as e:
raise MemphisSchemaError(str(e))
else:
raise MemphisSchemaError("Unsupported message type: {}".format(type(message).__name__))
except Exception as e:
raise MemphisSchemaError("Schema validation has failed: " + str(e))
Kindly review this! @shay23b
from memphis.py.
Hi @Adarsh-jaiss,
Sorry for the delay
So regarding the first point - dict already exists as a type that can be passed so it is not needed to add
And regarding the second one - it is not enough to just say what type is not supported, it would be better to describe what the user can do in order to fix his problem - so for example add the supported types to the error
If you will be working on this issue please let us know and open a PR when you're done.
This is how to contribute:
https://github.com/memphisdev/memphis.py/blob/master/CONTRIBUTING.md
from memphis.py.
Related Issues (20)
- [Discussion] Typing, tests, formatting, pre-commit HOT 4
- Stop consume functionality HOT 7
- Create formal documentation HOT 3
- Bug: Tries to access property of None instance HOT 2
- Bug: Missing method HOT 2
- Setup automated tests for PRs
- Bug: Review no-member error for ProtoBuf HOT 4
- Bug: Review no-member error for Exception status_code member HOT 6
- Re-enable E1101 message from Pylint
- Raise MemphisSchemaError rather then MemphisError HOT 1
- lint project using Ruff HOT 3
- Use separate connections for producers, consumers, etc.
- Inconsistent consumer name HOT 1
- Add examples to docstrings for consumer methods HOT 6
- Add task count limit to async produce
- Add error handling for async produce
- Drain or cancel waiting tasks when the producer is destroyed
- Support destroying existing consumers
- Change name of async producer parameter to "non-blocking"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memphis.py.