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

Argument as a substring int causes exception #52

Open
djolly-fuze opened this issue Jul 6, 2021 · 0 comments
Open

Argument as a substring int causes exception #52

djolly-fuze opened this issue Jul 6, 2021 · 0 comments

Comments

@djolly-fuze
Copy link

This sample extensions.conf

[macro-callerid-name-shorten]
exten => s,1,Set(CALLERID(name)=${CALLERID(name):0:${ARG1}})

causes an exception in asterisklint

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/asterisklint/config.py", line 186, in __iter__
    self.on_varset(element)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/dialplan.py", line 600, in on_varset
    dialplanvarset = DialplanVarset.from_varset(varset)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/dialplan.py", line 508, in from_varset
    app = App(app, varset.where)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/application.py", line 111, in __init__
    self.parse()
  File "/usr/local/lib/python3.9/site-packages/asterisklint/application.py", line 134, in parse
    self.data = self.parse_inner(self.data)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/application.py", line 149, in parse_inner
    data = VarLoader().parse_variables(data, self.where)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/varfun.py", line 288, in parse_variables
    inner_data = self._process_variable(
  File "/usr/local/lib/python3.9/site-packages/asterisklint/varfun.py", line 330, in _process_variable
    return FuncLoader().process_read_function(data, where)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/varfun.py", line 182, in process_read_function
    return ReadFuncSlice(func, args, start=start, length=length)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/variable.py", line 257, in __init__
    if length < 0:
TypeError: '<' not supported between instances of 'Var' and 'int'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/asterisklint", line 34, in <module>
    sys.exit(main(sys.argv[1:], os.environ))
  File "/usr/local/lib/python3.9/site-packages/asterisklint/main.py", line 178, in main
    return command_module.main(args, envs)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/mainutil.py", line 35, in __call__
    return self.handle_args(args)
  File "/usr/local/lib/python3.9/site-packages/asterisklint/commands/dialplan-check.py", line 50, in handle_args
    dialplan = next(iter(parser))
  File "/usr/local/lib/python3.9/site-packages/asterisklint/config.py", line 192, in __iter__
    raise ProgrammingError(str(element.where)) from exc
asterisklint.config.ProgrammingError: An unexpected exception was raised. This is most likely a bug in the asterisklint library. If you can reproduce the problem and file an issue on the bug tracker, that would be nice. Further info: extensions.conf:2

Replacing ${ARG1} with a hardcoded integer works as expected, but for my logic, it must be a variable.

I can't find a decent workaround as wrapping ARG1 with TRUNC and MATH function also produce similar comparison exceptions but different instances instead of 'Var', 'ReadFunc' and 'Expr' respectively.

@djolly-fuze djolly-fuze changed the title Argument in as a substring int causes exception Argument as a substring int causes exception Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant