Is it possible to change config value through leafref?

I have the following model

   container system1 {
     leaf system-name {
         type string;
         default "";
       }
  }
  container system3 {
      leaf system1Name {
          type leafref {
              path "/system1/system-name";
          }
      }
  }

If I try to set systems-name through leafref it fails:

    ubuntudsk1(config)# 
    ubuntudsk1(config)# system3 system1Name Linux
    ubuntudsk1(config)# commit
    Aborted: illegal reference 'system3 system1Name'
    ubuntudsk1(config)# 

is this supposed to work like this?

Assuming you don’t have any other commands/config written prior to the ones in your comment, yes…

By RFC definition, leafref is a “reference” to an item existing at the specified path (/system1/system-name in your case).
You don’t show any such command creating Linux in system1 system-name, so ConfD correctly rejects configuration as invalid - reference does not point to existing item…

The item has default value, so technically it should exist.
But even if I do the following it complains:

    ubuntudsk1(config)# system1 system-name Windows
    ubuntudsk1(config)# commit
    Aborted: illegal reference 'system3 system1Name'
    ubuntudsk1(config)# 

So, what’s wrong?

but default value shown in your excerpt is "" - empty string, and not “Linux” or “Windows” that you try to set as reference… type leafref means that it can hold values that do exist someplace else - on the path specified…

(leafref it is not a trigger that changes a node that path points to, but reads/validates against it)

xubuntu-dev(config)# system3 system1Name Linux
xubuntu-dev(config)# commit
Aborted: illegal reference 'system3 system1Name'
xubuntu-dev(config)# system1 system-name Linux
xubuntu-dev(config)# commit
Commit complete.

OK, thank you.
I guess I didn’t understand leafref correctly