DMTF / libredfish

libRedfish is a C client library that allows for Creation of Entities (POST), Read of Entities (GET), Update of Entities (PATCH), Deletion of Entities (DELETE), running Actions (POST), receiving events, and providing some basic query abilities.
Other
48 stars 22 forks source link

Broken Redpath #162

Closed Timboooh closed 1 year ago

Timboooh commented 1 year ago

Hey,

I'm having trouble using the library with RedPath. The [node.child] expression doesn't get parsed correctly.

Redpath works as expected when I use /Chassis[0]/Sensors[Status] But when I use /Chassis[0]/Sensors[Status.Health] nothing gets returned. I verified these do exist using the redfishcli demo from this repository.

The endnode looks like this in VSCode, when debugging with GDB:

I'm developing and running this application on Linux. And I use the Redfish-Interface-Emulator to test my application. If you need any additional information to be able to help please tell me.

Thanks a lot.

mraineri commented 1 year ago

It does look like you're using this correctly. @pboyd04 any ideas?

Timboooh commented 1 year ago

I'm not sure if it ever worked, because I can't find any parsing code for the [parent.child].

In redpath.c:165 the propname just gets set to index. (Status.Health in my example) with the REDPATH_OP_EXISTS operation. Then later, when this operation gets executed in payload.c this same path string gets used (as nodeName) when jansson is called: value = json_object_get(payload->json, nodeName) Only this function doesn't support json paths, only json keys.

I have two ideas on how I might be able to fix this:

  1. Add a json_object_get_by_path function and use it in payload.c which would be able to handle these json paths.
  2. Make redpath.c split this [parent.child] into two seperate redpathnodes that get handled separately.

IMHO option 1 is way simpler, and I already have working code that can handle json paths. I think I can implement it in payload.c, without breaking any current functionality. But I would have to test this first.

Let me know what you think about it.

Timboooh commented 1 year ago

Please see #163

mraineri commented 1 year ago

Fix merged