Literals which are unquoted strings not being verified for JSON syntax
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với script Python được cung cấp và entry point jmespath.search(), sau đó so sánh cách implementation xử lý các biểu thức literal với đặc tả JMESPath được liên kết cho literal-expressions. Xác nhận xem nội dung literal không được đặt trong dấu ngoặc kép có bắt buộc phải tạo ra lỗi cú pháp hay không, và kiểm tra hành vi với các trường hợp như wat, 3 và `{"foo": bar}”.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
My understanding based on the specification is that the content of a literal expression, i.e. the text between backticks, is supposed to be a valid JSON expression, otherwise it should be reported as a syntax error. The Python implementation seems to be treating them as strings instead, though. For example, this is accepted as a valid JMESPath expression:
thing == `wat`
even though I would think it should cause an error. Is this an actual bug in the Python implementation, or have I been misunderstanding the spec? (In the latter case I'd argue that the spec is misleading about this to the point of it being a documentation bug, but that's a separate issue.)
Here's a short script that demonstrates the error:
import jmespath, json, sys
literal_json = 'wat'
expression = f"thing == `{literal_json}`"
document = {"thing": "wat"}
try:
r = json.loads(literal_json)
except Exception as e:
print(f"json: parse error: {e.__class__.__name__}")
else:
print("json: no parse error")
print(f" result: {r!r}")
try:
r = jmespath.search(expression, document)
except Exception as e:
print(f"jmespath: parse error: {e.__class__.__name__}")
else:
print("jmespath: no parse error")
print(f" result: {r!r}")
It prints out the following:
$ python test-jmespath.py
json: parse error: JSONDecodeError
jmespath: no parse error
result: True
I would expect to see the jmespath part of the output be the same as the json part of the output, i.e. some kind of parsing error. And if I try other kinds of values, I do indeed get consistent results. For example, replacing the literal_json assignment line with literal_json = '3' gives
$ python test-jmespath.py
json: no parse error
result: 3
jmespath: no parse error
result: False
and if I replace it with literal_json = '{"foo": bar}' I get
$ python test-jmespath.py
json: parse error: JSONDecodeError
jmespath: parse error: LexerError
- Ngôn ngữ chính
- Python
- Star
- 2.5k
- Fork
- 231
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jmespath/jmespath.py
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
jmespath/jmespath.py#401 ·
-
floor() and ceil() raise OverflowError / ValueError on Infinity and NaNCó thể đã có người làm @guocn đã nhận 49 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
jmespath/jmespath.py#381 ·
-
Lexer gives quoted identifiers an `end` that is the token length, not its end offsetCó thể đã có người làm @chiliec đã nhận 50 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 20/100
jmespath/jmespath.py#380 ·
-
sdist is missing `tests/__init__.py`Có thể đã có người làm @deepakganesh78 đã nhận 127 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
jmespath/jmespath.py#341 · 1 bình luận ·
-
Different behavior on merge function between the JS lib and the Python libCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
jmespath/jmespath.py#329 · 1 bình luận ·
Tất cả issue của jmespath/jmespath.py
Issue tương tự
-
test_real_pandoc_failure_is_one_path_free_line fails on macOS CI with current Homebrew pandocĐang mởbug TAG: unit tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
learningequality/ricecooker#898 ·
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
freelawproject/litigant-portal#1285 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
least_squares returns a nonfinite objective for an invalid initial residualCó thể đã có người làm @sylvesterkaczmarek đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
google-deepmind/mujoco#4023 ·
Maintainer thường phản hồi trong vòng 11 ngày
-
Five Australian birds: Red-capped Parrot, Red-winged Fairywren, Gilbert’s Honeyeater, Western Spinebill, Western WattlebirdCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
arnegiacomo/fugleramme#427 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MONDO's zebu and cat Arnold-Chiari terms are is_a a dog disease (monarch-initiative/mondo#10939)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NCATSTranslator/Babel#1317 ·
Maintainer thường phản hồi trong vòng 2 ngày