Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

BUG: InsertPunctuationConverter accepts multi-character and empty punctuation_list entries

Cerrado
#3,292 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@ShivamSharma43 ya está trabajando en esto.

Desde el 18/10/2026.

  • #3294 de @ShivamSharma43 — fusionado

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
tooling

Línea de trabajo

Start by reading InsertPunctuationConverter.convert_async and _is_valid_punctuation, which the issue identifies as the relevant entry points. Check the existing converter tests and verify that multi-character entries, empty strings, and an empty list all produce the documented ValueError.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

InsertPunctuationConverter.convert_async documents punctuation_list as single characters from string.punctuation and raises ValueError for invalid entries ("Only single characters from ... are allowed"). But _is_valid_punctuation checks each entry with char in string.punctuation, which is a substring test, so it accepts:

  • multi-character runs that happen to be contiguous in string.punctuation, such as "()", "<=>", "{|}" or "./". These are inserted as-is, so a "double punctuation" that the docstring calls invalid ends up in the prompt.
  • the empty string, which inserts nothing while the converter reports its insertions as done.
  • an empty list, since all([]) is True. The converter then fails later with IndexError: Cannot choose from an empty sequence instead of the documented ValueError.

Multi-character entries that are not contiguous, such as "!?" or "~~", are already rejected, so the result depends on the order of characters in string.punctuation.

Steps/Code to Reproduce
import asyncio
from pyrit.converter import InsertPunctuationConverter

async def main():
    converter = InsertPunctuationConverter(word_swap_ratio=1, seed=1)
    for punctuation_list in (["<=>"], ["()"], [""], []):
        try:
            result = await converter.convert_async(prompt="hello big world", punctuation_list=punctuation_list)
            print(punctuation_list, repr(result.output_text))
        except Exception as e:
            print(punctuation_list, f"{type(e).__name__}: {e}")

asyncio.run(main())
Expected Results

Each call raises ValueError: Invalid punctuations: ....

Actual Results
['<=>'] '<=>hello <=>big world<=>'
['()'] '()hello ()big world()'
[''] 'hello big world'
[] IndexError: Cannot choose from an empty sequence
Screenshots

N/A

Versions
  • OS: Windows 11
  • Python version: 3.11.9
  • PyRIT version: installed from main (5b594e00) in editable mode
Lenguaje dominante
Python
Estrellas
4.6k
Forks
962
Merge medio
2 d 16 h
PR fusionados (30 d)
354

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/PyRIT

Todos los issues de microsoft/PyRIT

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.