TemplateSegmentConverter crashes on prompts shorter than the template parameter count
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/PyRIT
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
kristofdegrave/homeassistant-smart-charging#1413 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
nasa/earthdata-varinfo#113 ·
-
curriculum documentation quality
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
githubnext/gh-aw-workshop#3849 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day