Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

TemplateSegmentConverter crashes on prompts shorter than the template parameter count

Open Beginner friendly
#2,839 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
tooling

Research direction

Start at TemplateSegmentConverter and reproduce the two-word, five-parameter case described in the issue. Inspect the sampling of interior split points and the documented handling of leftover segments. Done means short prompts no longer raise ValueError, split at every available interior point, and leave remaining template parameters empty.

Written by the indexing model from the issue text.

Description

what happens

TemplateSegmentConverter raises ValueError: Sample larger than population or is negative for any prompt whose word count is between 2 and N-1 when the template has N parameters. the code samples min(len(words), N-1) interior split points but the population is only len(words)-1, so a 2-word prompt against a 5-parameter template tries to sample 2 from a population of 1.

the docstring promises empty leftover segments for short prompts, so this contradicts the documented behavior.

repro

words = ["attack", "target"]
num_params = 5
random.sample(range(1, len(words)), min(len(words), num_params - 1))
# ValueError: Sample larger than population

any converter template with more parameters than the prompt has words minus one hits it.

expected

short prompts split at every available interior point and leave the remaining template parameters empty, as documented.

env: main 5503ecb

Dominant language
Python
Stars
4.5k
Forks
896
Avg merge
3d 1h
Merged PRs (30d)
208

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/PyRIT

All issues in microsoft/PyRIT

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.