jorgebastida / jorgebastida/awslogs

JMESPath parse issue when using join function

Open
#403 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5k
Forks
342
PR merge metrics
No merged PRs in 30d

Description

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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.