<#5314 [BUG] ShellTask ctx.secrets accessors not w...
# flyte-github
c
#5314 [BUG] ShellTask ctx.secrets accessors not working with AWS Secrets Issue created by garretcook Hey Team, I'm attempting to use the convenient ctx.secrets replacement feature described here: flyteorg/flytekit#832 However, when using AWS Secrets, the task will not run in the local or remote mode. I would normally set it up like this:
Copy code
SECRET_GROUP='arn:aws:secretsmanager:region:id:secret:'
SECRET_KEY='secret-name:random5'
updater_cmd = ShellTask(
    name="task_3",
    debug=True,
    
    inputs=kwtypes(
        tenant_id=str, 
        redirect_url=str ,scope=str , 
        list_id=str ,site_id=str ,
        calendar_user=str, calendar_id=str, 
        update_sharepoint=str, update_calendar=str, 
        send_emails=str),
    script="""
    env;
    echo "test123";
    export CLIENT_ID={ctx.secrets.get('arn:aws:secretsmanager:region:id:secret:', 'secret-name:random5')};
    """,
    secret_requests=[
        Secret(
            group=SECRET_GROUP,
            key=SECRET_KEY,
            mount_requirement=Secret.MountType.ENV_VAR
        ),
    ]
)
Attempting to execute this returns:
Copy code
Last Error: SYSTEM::Traceback (most recent call last):

      File "/opt/venv/lib/python3.8/site-packages/flytekit/exceptions/scopes.py", line 178, in system_entry_point
        return wrapped(*args, **kwargs)
      File "/opt/venv/lib/python3.8/site-packages/flytekit/core/base_task.py", line 675, in dispatch_execute
        native_outputs = self.execute(**native_inputs)
      File "/opt/venv/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 314, in execute
        gen_script = self._interpolizer.interpolate(self._script, inputs=kwargs, outputs=outputs)
      File "/opt/venv/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 155, in interpolate
        return self._Formatter().format(tmpl, **consolidated_args)
      File "/usr/local/lib/python3.8/string.py", line 163, in format
        return self.vformat(format_string, args, kwargs)
      File "/usr/local/lib/python3.8/string.py", line 167, in vformat
        result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
      File "/usr/local/lib/python3.8/string.py", line 220, in _vformat
        result.append(self.format_field(obj, format_spec))
      File "/opt/venv/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 133, in format_field
        return super().format_field(value, format_spec)
      File "/usr/local/lib/python3.8/string.py", line 237, in format_field
        return format(value, format_spec)

Message:

    TypeError: unsupported format string passed to _GroupSecrets.__format__
@samhita-alla recommended I open a issue from Slack: https://flyte-org.slack.com/archives/CP2HDHKE1/p1714370085210499?thread_ts=1714162847.725119&cid=CP2HDHKE1 I can use the normal task syntax perfectly, even in the same file/workflow:
Copy code
@task(secret_requests=[
        Secret(
            group=SECRET_GROUP,
            key=SECRET_KEY,
        ),
])
def build_login_cmd():
    CREDENTIALS_LIST = flytekit.current_context().secrets.get(SECRET_GROUP, SECRET_KEY)
    print(CREDENTIALS_LIST)
flyteorg/flyte