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

JMESPath parse issue when using join function #403

Open
depau opened this issue Sep 5, 2024 · 0 comments
Open

JMESPath parse issue when using join function #403

depau opened this issue Sep 5, 2024 · 0 comments

Comments

@depau
Copy link

depau commented Sep 5, 2024

Hi, I'm getting the following error when reading logs from AppRunner:

Affected log line:

{'@timestamp': '2024-09-05T15:09:20.073Z', '@version': '1', 'logger_name': 'com.xxx.controller.authentication.JwtController', 'thread_name': 'http-nio-8080-exec-176', 'level': 'ERROR', 'level_value': 40000, 'application': 'xxxx'}

Query:

join(``, [(level == `WARN` && `\\u001b[33m` || level == `ERROR` && `\\u001b[31m` || level == `DEBUG` && `\\u001b[36m` || level == `INFO` && `\\u001b[32m` || ``), `[`, level, `] `, `\\u001b[0m`, `[`, thread_name, `] `, logger_name, `\\n`, message])
You've found a bug! Please, raise an issue attaching the following traceback
https://github.com/jorgebastida/awslogs/issues/new

Version:       0.15.0
Python:        3.12.5 (main, Aug  9 2024, 08:20:41) [GCC 14.2.1 20240805]
boto3 version: 1.35.12
Platform:      Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.39 (I wish it was real linux)
Args:          ['/home/davide.depau/test/venv/bin/awslogs', 'get', '-s', '1h', '-w', '-G', '--timestamp', '-q', 'join(``, [(level == `WARN` && `\\u001b[33m` || level == `ERROR` && `\\u001b[31m` || level == `DEBUG` && `\\u001b[36m` || level == `INFO` && `\\u001b[32m` || ``), `[`, level, `] `, `\\u001b[0m`, `[`, thread_name, `] `, logger_name, `\\n`, message])', '/aws/apprunner/REDACTED/REDACTED/application']
Config: {options}

Traceback (most recent call last):
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/awslogs/bin.py", line 210, in main
    getattr(logs, options.func)()
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/awslogs/core.py", line 219, in list_logs
    consumer()
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/awslogs/core.py", line 202, in consumer
    message = self.query_expression.search(parsed)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/parser.py", line 509, in search
    result = interpreter.visit(self.parsed, value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/visitor.py", line 94, in visit
    return method(node, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/visitor.py", line 171, in visit_function_expression
    return self._functions.call_function(node['value'], resolved_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/functions.py", line 80, in call_function
    self._validate_arguments(resolved_args, signature, function_name)
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/functions.py", line 91, in _validate_arguments
    return self._type_check(args, signature, function_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/functions.py", line 97, in _type_check
    self._type_check_single(actual[i], allowed_types,
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/functions.py", line 120, in _type_check_single
    self._subtype_check(current, allowed_subtypes,
  File "/home/davide.depau/test/venv/lib/python3.12/site-packages/jmespath/functions.py", line 144, in _subtype_check
    raise exceptions.JMESPathTypeError(
jmespath.exceptions.JMESPathTypeError: In function join(), invalid type for value: None, expected one of: ['array-string'], received: "NoneType"

I have jmespath==1.0.1.

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