Cdb_create() failed with badly formatted or nonexistent path

I tried to create a property based on openconfig-platform.yang,

    ret = cdb_create(sock, "/components/component{chassiscontroller}/"
                           "properties/property{%s}", property_name);

where debugged output shows property_name is a C string like “fw-version-cpld”. The call failed with -1 as the return value, and confd_strerror(confd_errno) shows “badly formatted or nonexistent path”. If I use an xml file with

chassiscontroller chassiscontroller ... fw-version-cpld fw-version-cpld ...

Then I can load the xml file during confd startup, and use the API successfully

    ret = cdb_cd(sock, "/components/component{chassiscontroller}/"
                       "properties/property{%s}/state", property_name);

What mistake do I make during cdb_create()? How can I fix it? Thanks.

Please see the ERRORS section of the confd_lib_lib(3) manual page. The confd_errno values are in most cases pretty generic, e.g. the CONFD_ERR_BADPATH that you encountered just means “there is something wrong with a path”, and confd_strerror() will only produce a fixed text with corresponding info (similar to libc strerror(3)). In cases where the problem isn’t obvious from the confd_errno value, more specific information will/should be provided by confd_lasterr().

So, please check what confd_lasterr() says in this case. Without looking at the YANG model, I can venture a guess that you are trying to create configuration data, which is not possible via the CDB API, since it must always be done through a transaction (i.e. you need to use the MAAPI API). The “write” functions in the CDB API can only be used to create/modify/delete operational (“config false”) data in CDB.

confd_lasterr() shows “Not a cdb operational data path”. I think I will need to use MAAPI API instead. Thanks for the quick response.