From 7039706e4d7d90284850a6ec7c5db98d9fa3d643 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sun, 1 Nov 2026 12:23:12 +0100 Subject: [PATCH] Fix nodeattrib -e for dotted attribute names in asynclient f9dc92ec fixed this in client.py, but nodeattrib has used asynclient.py since 76efea7c, so it still sends the underscored name (info_note instead of info.note) as the attribute, and a missing variable raises a KeyError instead of a usage error. Port the client.py logic over. --- confluent_client/confluent/asynclient.py | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/confluent_client/confluent/asynclient.py b/confluent_client/confluent/asynclient.py index 57bb4cbd..7583bbff 100644 --- a/confluent_client/confluent/asynclient.py +++ b/confluent_client/confluent/asynclient.py @@ -789,23 +789,31 @@ async def updateattrib(session, updateargs, nodetype, noderange, options, dictas sys.stderr.write('Error: ' + res['error'] + '\n') sys.exit(exitcode) elif hasattr(options, 'environment') and options.environment: - for key in updateargs[1:]: - key = key.replace('.', '_') - value = os.environ.get( - key, os.environ[key.upper()]) - # Let's do one pass to make sure that there's not a usage problem - for key in updateargs[1:]: - key = key.replace('.', '_') - value = os.environ.get( - key, os.environ[key.upper()]) + # The environment variable name substitutes '_' for '.' + attrvalues = {} + # Let's do one pass to make sure that there's not a usage problem + for attrib in updateargs[1:]: + envkey = attrib.replace('.', '_') + if envkey in os.environ: + attrvalues[attrib] = os.environ[envkey] + elif envkey.upper() in os.environ: + attrvalues[attrib] = os.environ[envkey.upper()] + else: + sys.stderr.write( + 'Error: {0} requested, but neither {1} nor {2} is set in ' + 'the environment\n'.format(attrib, envkey, envkey.upper())) + sys.exit(1) + for attrib in updateargs[1:]: if (nodetype == "nodegroups"): exitcode = await session.simple_nodegroups_command(noderange, 'attributes/all', - value, key) + attrvalues[attrib], + attrib) else: exitcode = await session.simple_noderange_command(noderange, 'attributes/all', - value, key) + attrvalues[attrib], + attrib) sys.exit(exitcode) elif dictassign: for key in dictassign: