Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unsupported format string passed to NoneType.__format__ in the docker image #286

Open
markrouz opened this issue Sep 14, 2023 · 1 comment
Labels
pending-review Waiting for a first review

Comments

@markrouz
Copy link

Describe the bug
[A clear and concise description of what the bug is.]
On this page of documentation:
(https://chaostoolkit.org//deployment/k8s/operator/#run-an-experiment-with-specific-extensions)
It's said "For instance, to install the Chaos Toolkit Kubernetes extension, create a Dockerfile like this. And the docker file is provided.
After building the image from this docker file and run this command (as it is mentioned in the doc):
docker run --rm -it my/chaostoolkit info extensions

I got the exception:

Traceback (most recent call last):
File "/usr/local/bin/chaos", line 8, in
sys.exit(cli())
^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/chaostoolkit/cli.py", line 554, in info
fmt.format(
TypeError: unsupported format string passed to NoneType.format

To Reproduce
Steps to reproduce the behavior.
Just follow the instruction from this section of the doc:
https://chaostoolkit.org//deployment/k8s/operator/#run-an-experiment-with-specific-extensions

Expected behavior
The list of extensions will be displayed.

Additional context
By the way, the provided dockerfile seems incorrect because there is no kubernetes extension inside it. But according to the above description it should be the case.

@markrouz markrouz added the pending-review Waiting for a first review label Sep 14, 2023
@cdsre
Copy link
Contributor

cdsre commented Mar 2, 2024

Followed the steps to reproduce this. Running an interactive shell in the container and editing the info.py to give output of the extension its processing it seems that chaostoolkit-addons doesnt have a licence string set.

/home/svc # chaos info extensions
NAME                                    VERSION   LICENSE                       DESCRIPTION                                       
#####################
ExtensionInfo(name='chaostoolkit-reliably', version='0.75.0', summary='Reliably CLI', license='Apache-2.0', author=None, url=None)
chaostoolkit-reliably                   0.75.0    Apache-2.0                    Reliably CLI
#####################
ExtensionInfo(name='chaostoolkit-addons', version='0.9.0', summary='Addons for your Chaos Toolkit experiments', license=None, author='Chaos Toolkit', url='https://chaostoolkit.org')
Traceback (most recent call last):

The info file is iterating over the extensions and wants to print a summary table that includes the licence type

        extensions = list_extensions()
        for extension in extensions:
            summary = extension.summary.replace(
                "Chaos Toolkit Extension for ", ""
            )[:50]
            click.echo(
                fmt.format(
                    extension.name,
                    extension.version,
                    extension.license,
                    summary,
                )
            )

I have only started learning chaostoolkit in the last few days so I am not sure if it is mandatory for all addons to provide a licence type or not. However if its not mandatory then something like the following in info.py could be used to create the string when the type is None.

            click.echo(                             
                fmt.format(              
                    extension.name, 
                    extension.version,
                    extension.license or "NONE",
                    summary,
                )
            )

OUTPUT

/home/svc # chaos info extensions
NAME                                    VERSION   LICENSE                       DESCRIPTION                                       
chaostoolkit-reliably                   0.75.0    Apache-2.0                    Reliably CLI                                      
chaostoolkit-addons                     0.9.0     NONE                          Addons for your Chaos Toolkit experiments

Alternatively if licence is a mandatory field for extensions then I would suggest the code should not load extensions when extensions = list_extensions() is called and in the chaoslib info.py it should only append after validating mandatory fields.

The more intermediate fix for this would be to update the chaostoolkit-addons project to export the licence like the chaostoolkit-reliably project does for example.

cdsre added a commit to cdsre/chaostoolkit that referenced this issue Mar 14, 2024
… This is to address issue chaostoolkit#286 where a package doesn't specify a licence and causes the info command to fail due to a None type trying to be formated.

Signed-off-by: Chris Doyle <uk.chris.doyle+cdsre@gmail.com>
@cdsre cdsre mentioned this issue Mar 14, 2024
cdsre added a commit to cdsre/chaostoolkit that referenced this issue Mar 14, 2024
… license which results in the python type being None. This commit will default extentions with no license infor with a value of 'Unkown'. This approach was discussed in chaostoolkit#299

Signed-off-by: Chris Doyle <uk.chris.doyle+cdsre@gmail.com>
Lawouach pushed a commit that referenced this issue Mar 15, 2024
…ch results in the python type being None. This commit will default extentions with no license infor with a value of 'Unkown'. This approach was discussed in #299

Signed-off-by: Chris Doyle <uk.chris.doyle+cdsre@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-review Waiting for a first review
Projects
None yet
Development

No branches or pull requests

2 participants