Skip to content

RDKEMW-24783: Videouput bad json (ser)deserialization - #108

Open
brendanobra wants to merge 19 commits into
developfrom
RDKEMW-24783
Open

RDKEMW-24783: Videouput bad json (ser)deserialization#108
brendanobra wants to merge 19 commits into
developfrom
RDKEMW-24783

Conversation

@brendanobra

Copy link
Copy Markdown
Contributor

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, and limited.

Root Cause

The previous implementation used a default enum marshaller path that did not match the actual wire format (string enums).

Changes

  • Added custom VideoOutput enum adapters for:
    • HdcpState
    • CecStateValue
    • RefreshRateValue
    • ColorDepthValue
    • ColorFormatValue
    • OutputColorimetry
    • DynamicRangeValue
    • QuantizationRangeValue
  • Updated VideoOutput getter/subscription wiring to use custom adapters instead of default enum marshalling.
  • Updated unit tests to validate string wire payloads (instead of enum ordinals).
  • Added component coverage for:
    • valid enum string parsing
    • invalid enum value rejection
    • runtime subscriptions:
      • VideoOutput.onHdcpChanged
      • VideoOutput.onCecStateChanged
      • VideoOutput.onRefreshRateChanged
  • Updated mock OpenRPC fixture by:
    • adding missing VideoOutput getter/event entries
    • correcting VideoOutput event result schemas to string-enum schemas

Validation

  • ./run-unit-tests.sh -> 170 passed
  • ./run-component-tests-local.sh --skip-image-build -> 107 passed, 0 failed, 0 skipped

Scope

Server-side alias behavior is out of scope. This PR is focused on client-side marshalling correctness and regression coverage.

brendanobra and others added 18 commits June 11, 2026 13:59
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
Copilot AI lite review requested due to automatic review settings September 9, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 VideoOutputImpl getters/subscriptions to decode enums using custom JsonData::*Json adapters (string wire values).
  • Added/updated unit + component tests to exercise string enum payloads and reject unknown values.
  • Updated the OpenRPC fixture with VideoOutput entries (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.

Comment on lines +4318 to +4328
"result": {
"name": "result",
"schema": {
"type": "string",
"enum": [
"active",
"inactive",
"unsupported"
]
}
}
Comment thread src/json_types/videooutput.h
Comment thread src/videooutput_impl.cpp
Comment on lines 45 to 52
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));
}
Comment thread docs/openrpc/the-spec/firebolt-open-rpc.json
Copilot AI review requested due to automatic review settings September 9, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants