r/PromptEngineering • • 23h ago

General Discussion Rerunning a generated codemod duplicated a plugin entry

A teammate ran one of our generated config codemods twice against the same sample repo. Pass one added the intended plugin entry. Pass two appended a second copy. We expect these scripts to get rerun during staggered upgrades, so I was surprised our fixtures had never exercised that path.

The helper generates migration scripts from a prompt. I use Braintrust to compare prompt variants against sample migration cases but our checks only inspect the repo after one execution. That check couldn't catch the append behavior.

I'm changing the fixture to retain the migrated repo and run the exact same generated script again. It will compare the config after each pass and assert there's still only one plugin entry. Regenerating code for the second pass would test something different, so the script stays fixed.

21 Upvotes

4 comments sorted by

2

u/Distinct-Lock-324 19h ago

seen this happen with a json config writer too, checked for a key-value pair, not the full object shape, so two runs merged configs instead of skipping. content diff should've caught it.

2

u/Awkward-Ear8342 17h ago

I've seen this with yaml configs too, checking for a key name wasn't enough, had to verify the full block structure. even a single extra space broke idempotency.

1

u/BroadlySociable 22h ago

An existing plugin entry with custom options seems like a useful follow-up fixture. A generated script that checks for the exact text it would insert could pass the rerun test and still append another copy beside a configured entry.

6

u/bytezvex 21h ago

yeah that’s a good edge case, the custom options part is where these things usually get weird. i’ve seen generated config edits act “idempotent” on the happy path and still duplicate when the existing entry isn’t the exact same shape, so that follow-up test feels pretty legit