Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#1,947 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@inchang-ing ci sta già lavorando.

Dal 20/10/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia in stripe/_encode.py, in _api_encode(), e confronta il ramo di liste/tuple con la gestione dei valori Boolean autonomi e dei valori contenuti in dizionari annidati. Poi esegui i test di codifica che coprono _api_encode() e aggiungi un caso per gli elementi Boolean in una lista. Il lavoro è concluso quando i valori dell’array codificato sono true e false in minuscolo, coerentemente con le altre posizioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Python
Stelle
2.1k
Fork
543
Merge medio
3g 21h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stripe/stripe-python

Tutte le issue di stripe/stripe-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.