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

Issues converting cache_dirs configuration option as list in _avocado/core/settings.py _as_list(value) method #5906

Closed
dnegreira opened this issue Apr 16, 2024 · 2 comments · Fixed by #5985
Assignees
Labels

Comments

@dnegreira
Copy link

Describe the bug
If I add a custom directory on avocado.conf with the example:

[datadir.paths]
base_dir = /build/avocado/data
logs_dir = /build/avocado/data/job-results
cache_dirs = /build/avocado/data/cache

At a certain point a method is called to convert the cache_dirs to a list, but ast will fail with an error since it contains special (/) characters in it.

Steps to reproduce
Can reproduce it in two ways:
By setting the above in avocado.conf and running python3.10 test --select=unit

After a bit of debugging I could find the same behavior that _as_list(value) is doing by following the quick example on python CLE.

>>> import ast
>>> bla = '/build/avocado/data/cache'
>>> print(ast.literal_eval(bla))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "/usr/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    /build/avocado/data/cache
    ^

Expected behavior
_as_list(value) should return the string as a list.

Current behavior
The above errors mentioned.

System information (please complete the following information):

  • OS: lsb_release -a
  • Ubuntu 22.04
  • Avocado version: avocado -v
  • 103
  • Avocado installation method: pip, rpm, github ?
  • Trying to package it in Ubuntu and failing unit tests :-)
    Maybe relevant to the bug:
    Python version: python3 3.10.6-1~22.04

Additional information
Currently working on an effort to package avocado-framework into Ubuntu/Debian.

@dnegreira dnegreira added the bug label Apr 16, 2024
@mr-avocado mr-avocado bot moved this to Triage in Default project Apr 16, 2024
@dnegreira
Copy link
Author

And of course I had to use a list as a value, not a string and that worked :)

@richtja
Copy link
Contributor

richtja commented Apr 16, 2024

Hi @dnegreira, thank you for reporting this. I can confirm that I was able to reproduce it.

@richtja richtja moved this from Triage to Short Term (Current Q) Backlog in Default project Apr 16, 2024
@richtja richtja self-assigned this Apr 16, 2024
@richtja richtja added this to the #106 - Codename TBD milestone May 6, 2024
@richtja richtja moved this from Short Term (Current Q) Backlog to In progress in Default project Jul 11, 2024
richtja added a commit to richtja/avocado that referenced this issue Jul 11, 2024
When there is an issue with syntax in avocado config file avocado won't
provide enough information for the user to understand the problem. This
commit will improve the error message by specifying the wrong value and
the reason for syntax error.

before this commit:
```
SyntaxError: Syntax error in config file ./pom_config, please check the
value /build/avocado/data/cache
```

after this commit:
```
ValueError: /build/avocado/data/cache could not be converted into a list
During handling of the above exception, another exception occurred:

SyntaxError: Syntax error in config file ./pom_config, please check the
value /build/avocado/data/cache
```

Reference: avocado-framework#5906
Signed-off-by: Jan Richter <[email protected]>
@richtja richtja linked a pull request Jul 11, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from In progress to Done 107 in Default project Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants