How to hide the path of leaf in error-message

please see the example below:

leaf  counter {
      tailf: hidden;
      must "current() <= 100" {
           error-message "the counter must be 0 ... 100";
      }
 }

the CLI could have this output:

Aborted: ‘XX YY ZZ counter’ (value “101”): the counter must be 0 … 100

Is there any way to change or hide the bold part of error-message ?

Yes. You need to do this change in an error formating callback that you register with ConfD in which you then format errors with the code “CONFD_ERR_MUST_FAILED”.

See confd_lib_dp man page section “ERROR FORMATTING CALLBACK” (also available as an appendix in the ConfD UG).
You have an example under “confd_error_seterr” that changes the “CONFD_ERR_TOO_MANY_ELEMS” error. You can do the same thing but for “CONFD_ERR_MUST_FAILED”.
Also note that you can for example check the context of the user, e.g. if the context is cli in the “struct confd_user_info”.

In addidtion, even though you didn’t ask for it, you can change the “Aborted:” prefix too. See confd.conf man page:
/confdConfig/cli/addErrorPrefixSuffix
/confdConfig/cli/cErrorPrefix
/confdConfig/cli/jErrorPrefix

1 Like

Thanks for your reply.

Well, I had to scrap the CALLBACK function because of the consideration of overhead time.
I truely want to change the ErrorPrefix of hidden leaves which cannot be seen by customers, while the unhidden leaves` error-messages could display as original.

/confdConfig/cli/addErrorPrefixSuffix 
/confdConfig/cli/cErrorPrefix
/confdConfig/cli/jErrorPrefix

Could these configurations restrict the appointed hidden leaves?
Look forward to your reply.

If you want to change the error message for hidden leaves only, one alternative can be to use the tailf:meta-data / value extensions in the YANG model in combination with the error formating callback that you register with ConfD.

How often will an error be triggered in your use case? Normally it is not a very frequent event.