Skip to content

Facing issue while using jmespath in docker #320

@sunilgsuthar

Description

@sunilgsuthar

So this is my file:

import jmespath
a = {
    "z": 2,
    "x": 3,
    "c": 4
}

e1 = "z + x"
e2 = "x * c"

print(jmespath.search(e1, a))
print(jmespath.search(e2, a))

Also this is my docker file:

FROM python:3.9-alpine

RUN pip install jmespath jmespath-community

COPY my-test.py .

CMD ["python", "my-test.py"]

The same code works when I just run the python file. But when run through docker, this throws these kind of errors:

  File "//my-test.py", line 12, in <module>
    print(jmespath.search(e1, a))
  File "/usr/local/lib/python3.9/site-packages/jmespath/__init__.py", line 12, in search
    return parser.Parser().parse(expression).search(data, options=options)
  File "/usr/local/lib/python3.9/site-packages/jmespath/parser.py", line 88, in parse
    parsed_result = self._do_parse(expression)
  File "/usr/local/lib/python3.9/site-packages/jmespath/parser.py", line 96, in _do_parse
    return self._parse(expression)
  File "/usr/local/lib/python3.9/site-packages/jmespath/parser.py", line 109, in _parse
    self._tokens = list(self.tokenizer)
  File "/usr/local/lib/python3.9/site-packages/jmespath/lexer.py", line 107, in tokenize
    raise LexerError(lexer_position=self._position,
jmespath.exceptions.LexerError: Bad jmespath expression: Unknown token +:
z + x

Is there something we are doing wrong? because the same code works on local, but not when deployed to a server through docker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions