RDKEMW-24783: Videouput bad json (ser)deserialization - #108
Conversation
Patch Release 0.6.1
Release 0.6.2
…t into chore/merge-to-main-from-develop
…t into chore/merge-to-main-from-develop
Chore/merge to main from develop
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ntral/firebolt-cpp-client into fix/videooutput-bad-marshalling
…nto fix/videooutput-bad-marshalling
There was a problem hiding this comment.
🟡 Changes recommended
It modifies files marked “AUTO-GENERATED — DO NOT EDIT” and the OpenRPC fixture updates are inconsistent/incomplete compared to established patterns, risking future regeneration or schema drift.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aims to fix VideoOutput enum marshalling by switching getter/subscription decoding from the default enum path to explicit JSON adapters that parse the wire’s string enum values, and adds regression coverage around valid/invalid parsing.
Changes:
- Updated
VideoOutputImplgetters/subscriptions to decode enums using customJsonData::*Jsonadapters (string wire values). - Added/updated unit + component tests to exercise string enum payloads and reject unknown values.
- Updated the OpenRPC fixture with
VideoOutputentries (but the fixture updates appear incomplete/inconsistent with existing event patterns).
File summaries
| File | Description |
|---|---|
src/videooutput_impl.cpp |
Switches VideoOutput enum decoding to custom JSON adapters for getters/subscriptions. |
src/json_types/videooutput.h |
Adds NL_Json_Basic adapters that map string wire values to VideoOutput enums. |
test/unit/videooutputGeneratedTest.cpp |
Updates unit tests to use string wire values + adds unknown-enum negative coverage. |
test/component/videooutputGeneratedTest.cpp |
Adds component/runtime coverage for enum parsing and subscription payload handling. |
docs/openrpc/the-spec/firebolt-open-rpc.json |
Adds VideoOutput OpenRPC entries and adjusts event schemas (currently inconsistent/incomplete). |
Review details
Suppressed comments (1)
docs/openrpc/the-spec/firebolt-open-rpc.json:4373
- OpenRPC event methods in this fixture consistently define the subscription call result schema as null (payload schema is derived via x-subscriber-for). This event currently defines a string-enum result schema, which is inconsistent with the rest of the fixture and can confuse schema consumers.
"result": {
"name": "result",
"schema": {
"type": "string",
"enum": [
- Files reviewed: 5/5 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "result": { | ||
| "name": "result", | ||
| "schema": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "active", | ||
| "inactive", | ||
| "unsupported" | ||
| ] | ||
| } | ||
| } |
| Result<HdcpState> VideoOutputImpl::hdcp() const | ||
| { | ||
| return helper_.get<Firebolt::JSON::BasicType<HdcpState>, HdcpState>("VideoOutput.hdcp"); | ||
| return helper_.get<JsonData::HdcpStateJson, HdcpState>("VideoOutput.hdcp"); | ||
| } | ||
| Result<SubscriptionId> VideoOutputImpl::subscribeOnHdcpChanged(std::function<void(const HdcpState&)>&& notification) | ||
| { | ||
| return subscriptionManager_.subscribe<Firebolt::JSON::BasicType<HdcpState>>("VideoOutput.onHdcpChanged", | ||
| std::move(notification)); | ||
| return subscriptionManager_.subscribe<JsonData::HdcpStateJson>("VideoOutput.onHdcpChanged", std::move(notification)); | ||
| } |
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies files explicitly marked “AUTO-GENERATED — DO NOT EDIT” and introduces OpenRPC event entries whose result schemas are internally inconsistent with their examples and established event patterns.
Review details
Suppressed comments (4)
src/videooutput_impl.cpp:51
- This file is marked as AUTO-GENERATED ("DO NOT EDIT"), but the implementation has been modified. To avoid future generator runs overwriting these changes, the fix should be applied in firebolt-sdk-gen and this file regenerated into the repo.
Result<HdcpState> VideoOutputImpl::hdcp() const
{
return helper_.get<JsonData::HdcpStateJson, HdcpState>("VideoOutput.hdcp");
}
Result<SubscriptionId> VideoOutputImpl::subscribeOnHdcpChanged(std::function<void(const HdcpState&)>&& notification)
{
return subscriptionManager_.subscribe<JsonData::HdcpStateJson>("VideoOutput.onHdcpChanged", std::move(notification));
docs/openrpc/the-spec/firebolt-open-rpc.json:4322
- The event method example returns null, but the declared result schema is a string enum. This makes the OpenRPC document internally inconsistent and diverges from other on*Changed methods in this file which use a null result schema (the payload is associated via x-subscriber-for).
"result": {
"name": "result",
"schema": {
"type": "string",
"enum": [
docs/openrpc/the-spec/firebolt-open-rpc.json:4373
- The event method example returns null, but the declared result schema is a string enum. This makes the OpenRPC document internally inconsistent and diverges from other on*Changed methods in this file which use a null result schema (the payload is associated via x-subscriber-for).
"result": {
"name": "result",
"schema": {
"type": "string",
"enum": [
src/json_types/videooutput.h:166
- This header is marked as AUTO-GENERATED ("DO NOT EDIT"), but it has been modified to add custom JSON adapter classes. To prevent future generator output from clobbering this logic, move these changes into firebolt-sdk-gen and regenerate the json_types header.
class CecStateValueJson : public Firebolt::JSON::NL_Json_Basic<::Firebolt::VideoOutput::CecStateValue>
{
public:
void fromJson(const nlohmann::json& json) override
{
cecStateValue_ = CecStateValueEnum.at(json.get<std::string>());
}
[[nodiscard]] ::Firebolt::VideoOutput::CecStateValue value() const override { return cecStateValue_; }
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
This PR fixes VideoOutput enum marshalling by replacing default enum decoding with explicit custom JSON adapters that correctly parse string wire payloads. The original pr is: #97
Problem
VideoOutput getters and subscriptions failed to parse valid payloads such as
hdcp1.4,inactive,ycbcr422,sdr, andlimited.Root Cause
The previous implementation used a default enum marshaller path that did not match the actual wire format (string enums).
Changes
Validation
./run-unit-tests.sh->170 passed./run-component-tests-local.sh --skip-image-build->107 passed, 0 failed, 0 skippedScope
Server-side alias behavior is out of scope. This PR is focused on client-side marshalling correctness and regression coverage.