这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fix ResourceData JSON format to use metadata objects

Problem

The MIDI-CI responder was sending incorrect Get Property Data Reply messages for ResourceData requests. Instead of sending an array of objects with metadata like:

[{"resource":"DeviceInfo"},{"resource":"ChannelList"},{"resource":"JSONSchema"},{"resource":"X-6847"}]

It was sending a simple string array:

["DeviceInfo","ChannelList","JSONSchema"]

Solution

This PR ports the missing CommonRulesPropertyMetadata.toJsonValue() function from the Kotlin ktmidi implementation to C++ and updates the ResourceData response generation to use metadata objects instead of plain strings.

Changes Made

  1. Added missing constants to PropertyCommonRules.hpp:

    • PropertyResourceFields struct with field name constants (RESOURCE, CAN_GET, CAN_SET, etc.)
    • PropertySetAccess struct with access level constants (NONE, FULL, PARTIAL)
  2. Implemented toJsonValue() method in CommonRulesPropertyMetadata:

    • Ported the conditional field inclusion logic from Kotlin
    • Only includes non-default values to keep JSON compact
    • Handles all metadata fields: resource, canGet, canSet, canSubscribe, requireResId, mediaTypes, encodings, schema, canPaginate
  3. Updated create_resource_list_json() in CommonRulesPropertyService:

    • Changed from creating simple string arrays to using metadata objects
    • Uses dynamic casting to handle different metadata types
    • Provides fallback metadata creation for non-CommonRules properties

Technical Details

  • The implementation follows the exact same conditional logic as the Kotlin version
  • Uses the existing json_ish library consistently with codebase patterns
  • Maintains backward compatibility by not changing core metadata structure
  • Includes proper error handling for schema parsing

Testing

  • Project builds successfully with no compilation errors
  • All existing functionality preserved
  • ResourceData responses now return proper JSON objects with metadata

Link to Devin run

https://app.devin.ai/sessions/9a977e94459d49d0bd682cf0c87ed22e

Requested by

Atsushi Eno (atsushieno@gmail.com)

- Port CommonRulesPropertyMetadata.toJsonValue() from Kotlin implementation
- Add PropertyResourceFields and PropertySetAccess constants to PropertyCommonRules.hpp
- Update create_resource_list_json() to generate objects instead of strings
- ResourceList now returns [{'resource':'DeviceInfo'},...] instead of ['DeviceInfo',...]

This fixes the MIDI-CI responder's Get Property Data Reply message for ResourceData
requests to send the correct JSON format with metadata objects rather than plain strings.

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@atsushieno atsushieno merged commit 1ab615a into main Jun 19, 2025
3 checks passed
@atsushieno atsushieno deleted the devin/1750357918-fix-resourcedata-json-format branch June 19, 2025 18:45
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.

2 participants