Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

AssertionError when trying to POST with bearer auth

Đang mở
#1,614 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu trong httpie/cli/argparser.py tại _guess_method(), sử dụng lệnh POST và traceback được báo cáo để tái hiện AssertionError. Theo dõi cách các đối số bearer-auth và URL được phân tích, sau đó xác minh rằng lời gọi không hợp lệ tạo ra một thông báo lỗi hữu ích thay vì lỗi assertion.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug new

Checklist

  • I've searched for similar issues.
  • I'm using the latest version of HTTPie.

Minimal reproduction code and steps

/Users/Khayet https POST --auth-type bearer --auth $TOKEN "https://example.org"

Current result

Traceback (most recent call last):
  File "/opt/homebrew/bin/http", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/__main__.py", line 9, in main
    exit_status = main()
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/core.py", line 162, in main
    return raw_main(
        parser=parser,
    ...<2 lines>...
        env=env
    )
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/core.py", line 77, in raw_main
    parsed_args = parser.parse_args(
        args=args,
        env=env,
    )
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/cli/argparser.py", line 176, in parse_args
    self._guess_method()
    ~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/cli/argparser.py", line 416, in _guess_method
    assert not self.args.request_items
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Expected result

Probably an error message telling me what is wrong about the invocation and how to do it correctly. I'm new to httpie and guess that I did something wrong but I don't know what. https --help is telling me that the method parameter comes directly after the https command but maybe the problem is that the url is in the wrong place and httpie gets confused due to the auth parameters?

Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

/Users/Khayet https POST --auth-type bearer --auth $TOKEN "https://example.org" --debug
HTTPie 3.2.4
Requests 2.32.3
Pygments 2.18.0
Python 3.13.1 (main, Dec  3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)]
/opt/homebrew/Cellar/httpie/3.2.4/libexec/bin/python
Darwin 24.3.0

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x106628220>,
 'args': Namespace(),
 'as_silent': <function Environment.as_silent at 0x1066280e0>,
 'colors': 256,
 'config': {'default_options': []},
 'config_dir': PosixPath('/Users/jakob.herpel/.config/httpie'),
 'devnull': <property object at 0x106609530>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x106628180>,
 'program_name': 'http',
 'quiet': 0,
 'rich_console': <functools.cached_property object at 0x105ba1fd0>,
 'rich_error_console': <functools.cached_property object at 0x1066005a0>,
 'show_displays': True,
 'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
 'stderr_isatty': True,
 'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
 'stdin_encoding': 'utf-8',
 'stdin_isatty': True,
 'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
 'stdout_encoding': 'utf-8',
 'stdout_isatty': True}>

<PluginManager {'adapters': [],
 'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
          <class 'httpie.plugins.builtin.DigestAuthPlugin'>,
          <class 'httpie.plugins.builtin.BearerAuthPlugin'>],
 'converters': [],
 'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
                <class 'httpie.output.formatters.json.JSONFormatter'>,
                <class 'httpie.output.formatters.xml.XMLFormatter'>,
                <class 'httpie.output.formatters.colors.ColorFormatter'>]}>
Traceback (most recent call last):
  File "/opt/homebrew/bin/http", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/__main__.py", line 9, in main
    exit_status = main()
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/core.py", line 162, in main
    return raw_main(
        parser=parser,
    ...<2 lines>...
        env=env
    )
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/core.py", line 77, in raw_main
    parsed_args = parser.parse_args(
        args=args,
        env=env,
    )
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/cli/argparser.py", line 176, in parse_args
    self._guess_method()
    ~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/httpie/3.2.4/libexec/lib/python3.13/site-packages/httpie/cli/argparser.py", line 416, in _guess_method
    assert not self.args.request_items
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Additional information, screenshots, or code examples

…

Ngôn ngữ chính
Python
Star
38.6k
Fork
4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của httpie/cli

Tất cả issue của httpie/cli

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.