Adding attributes to a reference node in Maya

I’m trying to add attributes to a reference. Has anyone managed to do this? I’m in Maya 2017 Update4 and I’m getting the following error, even though the reference is not locked:

# Warning: 'JAGRN' is locked so attributes may not be added to it. # 
# Error: RuntimeError: file d:\Eidos_Cinematic_Dept\Tools\Shared\scripts\dcc\_maya\scene.py line 664: Found no valid items to add the attribute to. #

It looks like the reference can be unlocked, but the reference NODE is still locked.

cmds.addAttr('JAGRN',ln='foo',at='float') #fail
cmds.getAttr('JAGRN.locked') #false, reference isn't locked.
cmds.lockNode('JAGRN',q=1,lock=1) # but the reference node is?
cmds.lockNode('JAGRN',lock=0) #unlock it
cmds.addAttr('JAGRN',ln='foo',at='float') #works now?

[Monumental facepalm]

Thanks katz.