-
Notifications
You must be signed in to change notification settings - Fork 75
[Beginner]: Validate protobuf parsing in TopicId::fromBytes #1367
Copy link
Copy link
Labels
kind: enhancementImprovement to existing code or performance without adding new featuresImprovement to existing code or performance without adding new featurespriority: lowNon-urgent tasks, nice-to-have improvements, or minor issuesNon-urgent tasks, nice-to-have improvements, or minor issuesskill: beginnerSuitable for contributors who have completed a good first issue and want to build skillsSuitable for contributors who have completed a good first issue and want to build skills
Milestone
Metadata
Metadata
Assignees
Labels
kind: enhancementImprovement to existing code or performance without adding new featuresImprovement to existing code or performance without adding new featurespriority: lowNon-urgent tasks, nice-to-have improvements, or minor issuesNon-urgent tasks, nice-to-have improvements, or minor issuesskill: beginnerSuitable for contributors who have completed a good first issue and want to build skillsSuitable for contributors who have completed a good first issue and want to build skills
Type
Fields
Give feedbackNo fields configured for Bug.
🐥 Beginner Friendly
This issue is a great fit for contributors who are ready to explore the Hiero C++ codebase a little more and take on slightly more independent work.
Beginner Issues often involve reading existing C++ code, understanding how different parts of the SDK fit together, and making small, thoughtful updates that follow established patterns.
The goal is to support skill growth while keeping the experience approachable, well-scoped, and enjoyable.
Important
Comment
/assignon the GitHub issue to request assignment before starting work.👾 Description of the Task
TopicId::fromBytes()currently parses protobuf bytes without checking whether parsing succeeded.Current implementation:
If invalid bytes are provided,
ParseFromArray(...)may fail and the function can still return a default/invalid-lookingTopicIdinstead of failing fast.Relevant files:
💡 Proposed Solution
Update
TopicId::fromBytes()to validate the parse result and throw a clearstd::invalid_argumentwhen bytes cannot be parsed intoproto::TopicID.Also add a unit test that passes invalid bytes and verifies an exception is thrown.
This should be a narrow change:
TopicId.cc)TopicIdUnitTests.cc)👩💻 Implementation Steps
src/sdk/main/src/TopicId.ccand locateTopicId::fromBytes()fromBytes()to check the return value ofParseFromArray(...)std::invalid_argumentwith a descriptive message when parse failssrc/sdk/tests/unit/TopicIdUnitTests.ccTopicId::fromBytes(...)throwsFromByteshappy-path test still passes✅ Acceptance Criteria
src/sdk/main/src/TopicId.ccandsrc/sdk/tests/unit/TopicIdUnitTests.ccstd::invalid_argumentinTopicId::fromBytes()📋 Step-by-Step Contribution Guide
/assignto request assignmentREADME.md-s -SRead Workflow Guide for step-by-step workflow guidance. Read README.md for setup instructions.
❗ Pull requests cannot be merged without
Sandssigned commits. See the Signing Guide.🤔 Additional Information
This improves SDK robustness by preventing silent fallback behavior on malformed input bytes.
If you have questions while working on this issue, feel free to ask!
You can reach the community and maintainers here: Hiero-SDK-C++ Discord
Whether you need help finding the right file, understanding existing code, or confirming your approach — we're happy to help.