Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Boolean list elements are encoded as True/False instead of true/false

オープン 初心者向け
#1,947 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@inchang-ing がすでに取り組んでいます。

2026年10月20日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

stripe/_encode.py の _api_encode() から始め、リスト/タプルの分岐と、単独の値およびネストされた辞書の値に対する Boolean の処理を比較してください。次に、_api_encode() を対象とするエンコードテストを実行し、リスト内の Boolean 要素のケースを追加してください。エンコードされた配列の値が小文字の true と false になり、他の位置の値と一貫していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug
Describe the bug
Description

stripe._encode._api_encode() serializes Boolean values inconsistently depending on their position in the request parameters.

Top-level and nested-dictionary Booleans become lowercase true / false, but Booleans directly inside lists remain Python True / False when URL-encoded.

Minimal reproduction
from urllib.parse import urlencode
from stripe._encode import _api_encode

cases = {
    "standalone": {"enabled": True},
    "array": {"enabled": [True, False]},
    "nested": {"enabled": {"flag": True}},
}

for name, params in cases.items():
    print(name, urlencode(list(_api_encode(params))))
Actual behavior
standalone enabled=true
array enabled%5B0%5D=True&enabled%5B1%5D=False
nested enabled%5Bflag%5D=true
Expected behavior

Boolean array elements should be serialized consistently as lowercase true and false.

Root cause

The list/tuple branch of _api_encode() yields scalar array elements directly without applying the Boolean conversion used elsewhere.

Source:
https://github.com/stripe/stripe-python/blob/master/stripe/_encode.py

Existing tests cover top-level Boolean values and lists separately, but not Booleans directly inside lists.

Verification

Reproduced locally using the current upstream _api_encode() implementation in an isolated Python harness.

No live Stripe API request was made, and the full installed SDK test suite was not executed. The potential impact on specific API endpoints has not yet been established.

To Reproduce
  1. Use the current "stripe-python" "_api_encode()" implementation.
  2. Run the Python example provided in the Minimal reproduction section above. No Stripe API key or network access is required.
  3. Compare the URL-encoded output for standalone, nested, and array Boolean values.
  4. Observe that standalone and nested Booleans become lowercase "true" / "false", while array elements become uppercase "True" / "False".
  5. Expected: All Boolean values should use consistent lowercase encoding regardless of nesting.
Expected behavior

Boolean values should be consistently serialized as lowercase "true" and "false", regardless of whether they appear as standalone values, nested dictionary fields, or array elements.

For example:

enabled%5B0%5D=true&enabled%5B1%5D=false

Instead of:

enabled%5B0%5D=True&enabled%5B1%5D=False

The encoded representation should not depend on the nesting structure.

Code snippets

OS

ubuntu

Language version

Python 3.13

Library version

Development branch (master); isolated source reproduction, no installed SDK

API version

N/A — no Stripe API request performed

Additional context

No response

主要言語
Python
スター
2.1k
フォーク
539
平均マージ
3日 5時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stripe/stripe-python のほかの issue

stripe/stripe-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。